diff --git a/gen/adexchangebuyer1d3-cli/Cargo.toml b/gen/adexchangebuyer1d3-cli/Cargo.toml index 263cd565fa..119cd0479b 100644 --- a/gen/adexchangebuyer1d3-cli/Cargo.toml +++ b/gen/adexchangebuyer1d3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adexchangebuyer1d3-cli" -version = "0.3.6+20160831" +version = "1.0.0+20160831" authors = ["Sebastian Thiel "] description = "A complete library to interact with Ad Exchange Buyer (protocol v1.3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adexchangebuyer1d3-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-adexchangebuyer1d3/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-adexchangebuyer1d3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-adexchangebuyer1d3/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-adexchangebuyer1d3] path = "../adexchangebuyer1d3" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/adexchangebuyer1d3-cli/README.md b/gen/adexchangebuyer1d3-cli/README.md index 76030a5319..eb52bc6945 100644 --- a/gen/adexchangebuyer1d3-cli/README.md +++ b/gen/adexchangebuyer1d3-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Ad Exchange Buyer* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/adexchangebuyer1d3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/adexchangebuyer1d3.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/adexchangebuyer1d3.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/adexchangebuyer1d3.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/adexchangebuyer1d3-cli). # Usage -This documentation was generated from the *Ad Exchange Buyer* API at revision *20160831*. The CLI is at version *0.3.6*. +This documentation was generated from the *Ad Exchange Buyer* API at revision *20160831*. The CLI is at version *1.0.0*. ```bash adexchangebuyer1d3 [options] diff --git a/gen/adexchangebuyer1d3-cli/mkdocs.yml b/gen/adexchangebuyer1d3-cli/mkdocs.yml index 91f630128f..5e14814e1a 100644 --- a/gen/adexchangebuyer1d3-cli/mkdocs.yml +++ b/gen/adexchangebuyer1d3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Ad Exchange Buyer v0.3.6+20160831 +site_name: Ad Exchange Buyer v1.0.0+20160831 site_url: http://byron.github.io/google-apis-rs/google-adexchangebuyer1d3-cli site_description: Write integrating applications with bcore diff --git a/gen/adexchangebuyer1d3-cli/src/main.rs b/gen/adexchangebuyer1d3-cli/src/main.rs index 1d7cc7d720..2ed3752bb1 100644 --- a/gen/adexchangebuyer1d3-cli/src/main.rs +++ b/gen/adexchangebuyer1d3-cli/src/main.rs @@ -2303,7 +2303,7 @@ fn main() { let mut app = App::new("adexchangebuyer1d3") .author("Sebastian Thiel ") - .version("0.3.6+20160831") + .version("1.0.0+20160831") .about("Accesses your bidding-account information, submits creatives for validation, finds available direct deals, and retrieves performance reports.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_adexchangebuyer1d3_cli") .arg(Arg::with_name("url") diff --git a/gen/adexchangebuyer1d4-cli/Cargo.toml b/gen/adexchangebuyer1d4-cli/Cargo.toml index 3ba1a9ef49..75d89837c0 100644 --- a/gen/adexchangebuyer1d4-cli/Cargo.toml +++ b/gen/adexchangebuyer1d4-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adexchangebuyer1d4-cli" -version = "0.3.6+20160831" +version = "1.0.0+20160831" authors = ["Sebastian Thiel "] description = "A complete library to interact with Ad Exchange Buyer (protocol v1.4)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adexchangebuyer1d4-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-adexchangebuyer1d4/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-adexchangebuyer1d4/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-adexchangebuyer1d4/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-adexchangebuyer1d4] path = "../adexchangebuyer1d4" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/adexchangebuyer1d4-cli/README.md b/gen/adexchangebuyer1d4-cli/README.md index bb5aea0456..95df4607bf 100644 --- a/gen/adexchangebuyer1d4-cli/README.md +++ b/gen/adexchangebuyer1d4-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Ad Exchange Buyer* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/adexchangebuyer1d4.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/adexchangebuyer1d4.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/adexchangebuyer1d4.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/adexchangebuyer1d4.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/adexchangebuyer1d4-cli). # Usage -This documentation was generated from the *Ad Exchange Buyer* API at revision *20160831*. The CLI is at version *0.3.6*. +This documentation was generated from the *Ad Exchange Buyer* API at revision *20160831*. The CLI is at version *1.0.0*. ```bash adexchangebuyer1d4 [options] diff --git a/gen/adexchangebuyer1d4-cli/mkdocs.yml b/gen/adexchangebuyer1d4-cli/mkdocs.yml index 51c2df95e9..7359704ad8 100644 --- a/gen/adexchangebuyer1d4-cli/mkdocs.yml +++ b/gen/adexchangebuyer1d4-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Ad Exchange Buyer v0.3.6+20160831 +site_name: Ad Exchange Buyer v1.0.0+20160831 site_url: http://byron.github.io/google-apis-rs/google-adexchangebuyer1d4-cli site_description: Write integrating applications with bcore diff --git a/gen/adexchangebuyer1d4-cli/src/main.rs b/gen/adexchangebuyer1d4-cli/src/main.rs index 592e2daa06..538a639d40 100644 --- a/gen/adexchangebuyer1d4-cli/src/main.rs +++ b/gen/adexchangebuyer1d4-cli/src/main.rs @@ -3990,7 +3990,7 @@ fn main() { let mut app = App::new("adexchangebuyer1d4") .author("Sebastian Thiel ") - .version("0.3.6+20160831") + .version("1.0.0+20160831") .about("Accesses your bidding-account information, submits creatives for validation, finds available direct deals, and retrieves performance reports.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_adexchangebuyer1d4_cli") .arg(Arg::with_name("url") diff --git a/gen/adexchangeseller2-cli/Cargo.toml b/gen/adexchangeseller2-cli/Cargo.toml index 159e88d07b..47ae94e4a0 100644 --- a/gen/adexchangeseller2-cli/Cargo.toml +++ b/gen/adexchangeseller2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adexchangeseller2-cli" -version = "0.3.6+20160805" +version = "1.0.0+20160805" authors = ["Sebastian Thiel "] description = "A complete library to interact with Ad Exchange Seller (protocol v2.0)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adexchangeseller2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-adexchangeseller2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-adexchangeseller2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-adexchangeseller2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-adexchangeseller2] path = "../adexchangeseller2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/adexchangeseller2-cli/README.md b/gen/adexchangeseller2-cli/README.md index a4fc75050a..049b7d6fef 100644 --- a/gen/adexchangeseller2-cli/README.md +++ b/gen/adexchangeseller2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Ad Exchange Seller* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/adexchangeseller2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/adexchangeseller2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/adexchangeseller2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/adexchangeseller2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/adexchangeseller2-cli). # Usage -This documentation was generated from the *Ad Exchange Seller* API at revision *20160805*. The CLI is at version *0.3.6*. +This documentation was generated from the *Ad Exchange Seller* API at revision *20160805*. The CLI is at version *1.0.0*. ```bash adexchangeseller2 [options] diff --git a/gen/adexchangeseller2-cli/mkdocs.yml b/gen/adexchangeseller2-cli/mkdocs.yml index 918e4b1008..3b86a7ddc5 100644 --- a/gen/adexchangeseller2-cli/mkdocs.yml +++ b/gen/adexchangeseller2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Ad Exchange Seller v0.3.6+20160805 +site_name: Ad Exchange Seller v1.0.0+20160805 site_url: http://byron.github.io/google-apis-rs/google-adexchangeseller2-cli site_description: Write integrating applications with bcore diff --git a/gen/adexchangeseller2-cli/src/main.rs b/gen/adexchangeseller2-cli/src/main.rs index f3ad3b5453..4233ebdae5 100644 --- a/gen/adexchangeseller2-cli/src/main.rs +++ b/gen/adexchangeseller2-cli/src/main.rs @@ -1347,7 +1347,7 @@ fn main() { let mut app = App::new("adexchangeseller2") .author("Sebastian Thiel ") - .version("0.3.6+20160805") + .version("1.0.0+20160805") .about("Accesses the inventory of Ad Exchange seller users and generates reports.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_adexchangeseller2_cli") .arg(Arg::with_name("url") diff --git a/gen/admin1_directory-cli/Cargo.toml b/gen/admin1_directory-cli/Cargo.toml index 07f8e103ff..71d0a20844 100644 --- a/gen/admin1_directory-cli/Cargo.toml +++ b/gen/admin1_directory-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-admin1_directory-cli" -version = "0.3.6+20160824" +version = "1.0.0+20160824" authors = ["Sebastian Thiel "] description = "A complete library to interact with directory (protocol directory_v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_directory-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-admin1_directory/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-admin1_directory/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-admin1_directory/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-admin1_directory] path = "../admin1_directory" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/admin1_directory-cli/README.md b/gen/admin1_directory-cli/README.md index 5f9832ab84..565c76f083 100644 --- a/gen/admin1_directory-cli/README.md +++ b/gen/admin1_directory-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *directory* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/admin1-directory.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/admin1-directory.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/admin1-directory.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/admin1-directory.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_directory-cli). # Usage -This documentation was generated from the *directory* API at revision *20160824*. The CLI is at version *0.3.6*. +This documentation was generated from the *directory* API at revision *20160824*. The CLI is at version *1.0.0*. ```bash admin1-directory [options] diff --git a/gen/admin1_directory-cli/mkdocs.yml b/gen/admin1_directory-cli/mkdocs.yml index 86e1a58f55..3f90aced7f 100644 --- a/gen/admin1_directory-cli/mkdocs.yml +++ b/gen/admin1_directory-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: directory v0.3.6+20160824 +site_name: directory v1.0.0+20160824 site_url: http://byron.github.io/google-apis-rs/google-admin1_directory-cli site_description: Write integrating applications with bcore diff --git a/gen/admin1_directory-cli/src/main.rs b/gen/admin1_directory-cli/src/main.rs index 8ad2c60589..dc84238cd4 100644 --- a/gen/admin1_directory-cli/src/main.rs +++ b/gen/admin1_directory-cli/src/main.rs @@ -9683,7 +9683,7 @@ fn main() { let mut app = App::new("admin1-directory") .author("Sebastian Thiel ") - .version("0.3.6+20160824") + .version("1.0.0+20160824") .about("The Admin SDK Directory API lets you view and manage enterprise resources such as users and groups, administrative notifications, security features, and more.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_admin1_directory_cli") .arg(Arg::with_name("url") diff --git a/gen/admin1_reports-cli/Cargo.toml b/gen/admin1_reports-cli/Cargo.toml index 69af944ec5..eff1c09b2e 100644 --- a/gen/admin1_reports-cli/Cargo.toml +++ b/gen/admin1_reports-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-admin1_reports-cli" -version = "0.3.6+20160704" +version = "1.0.0+20160704" authors = ["Sebastian Thiel "] description = "A complete library to interact with reports (protocol reports_v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_reports-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-admin1_reports/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-admin1_reports/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-admin1_reports/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-admin1_reports] path = "../admin1_reports" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/admin1_reports-cli/README.md b/gen/admin1_reports-cli/README.md index e3111971cf..50ac83dc26 100644 --- a/gen/admin1_reports-cli/README.md +++ b/gen/admin1_reports-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *reports* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/admin1-reports.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/admin1-reports.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/admin1-reports.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/admin1-reports.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_reports-cli). # Usage -This documentation was generated from the *reports* API at revision *20160704*. The CLI is at version *0.3.6*. +This documentation was generated from the *reports* API at revision *20160704*. The CLI is at version *1.0.0*. ```bash admin1-reports [options] diff --git a/gen/admin1_reports-cli/mkdocs.yml b/gen/admin1_reports-cli/mkdocs.yml index 5977a6d002..ac95bd98f5 100644 --- a/gen/admin1_reports-cli/mkdocs.yml +++ b/gen/admin1_reports-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: reports v0.3.6+20160704 +site_name: reports v1.0.0+20160704 site_url: http://byron.github.io/google-apis-rs/google-admin1_reports-cli site_description: Write integrating applications with bcore diff --git a/gen/admin1_reports-cli/src/main.rs b/gen/admin1_reports-cli/src/main.rs index 5efde40353..ca76c4cf02 100644 --- a/gen/admin1_reports-cli/src/main.rs +++ b/gen/admin1_reports-cli/src/main.rs @@ -735,7 +735,7 @@ fn main() { let mut app = App::new("admin1-reports") .author("Sebastian Thiel ") - .version("0.3.6+20160704") + .version("1.0.0+20160704") .about("Fetches reports for the administrators of Google Apps customers about the usage, collaboration, security, and risk for their users.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_admin1_reports_cli") .arg(Arg::with_name("url") diff --git a/gen/adsense1d4-cli/Cargo.toml b/gen/adsense1d4-cli/Cargo.toml index 53d0bf489c..365ef01385 100644 --- a/gen/adsense1d4-cli/Cargo.toml +++ b/gen/adsense1d4-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adsense1d4-cli" -version = "0.3.6+20160907" +version = "1.0.0+20160907" authors = ["Sebastian Thiel "] description = "A complete library to interact with AdSense (protocol v1.4)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adsense1d4-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-adsense1d4/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-adsense1d4/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-adsense1d4/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-adsense1d4] path = "../adsense1d4" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/adsense1d4-cli/README.md b/gen/adsense1d4-cli/README.md index dceda8a8a3..42c32b6897 100644 --- a/gen/adsense1d4-cli/README.md +++ b/gen/adsense1d4-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *AdSense* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/adsense1d4.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/adsense1d4.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/adsense1d4.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/adsense1d4.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/adsense1d4-cli). # Usage -This documentation was generated from the *AdSense* API at revision *20160907*. The CLI is at version *0.3.6*. +This documentation was generated from the *AdSense* API at revision *20160907*. The CLI is at version *1.0.0*. ```bash adsense1d4 [options] diff --git a/gen/adsense1d4-cli/mkdocs.yml b/gen/adsense1d4-cli/mkdocs.yml index 84c730de81..d221b340cb 100644 --- a/gen/adsense1d4-cli/mkdocs.yml +++ b/gen/adsense1d4-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: AdSense v0.3.6+20160907 +site_name: AdSense v1.0.0+20160907 site_url: http://byron.github.io/google-apis-rs/google-adsense1d4-cli site_description: Write integrating applications with bcore diff --git a/gen/adsense1d4-cli/src/main.rs b/gen/adsense1d4-cli/src/main.rs index d25b909428..088914232a 100644 --- a/gen/adsense1d4-cli/src/main.rs +++ b/gen/adsense1d4-cli/src/main.rs @@ -3480,7 +3480,7 @@ fn main() { let mut app = App::new("adsense1d4") .author("Sebastian Thiel ") - .version("0.3.6+20160907") + .version("1.0.0+20160907") .about("Accesses AdSense publishers' inventory and generates performance reports.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_adsense1d4_cli") .arg(Arg::with_name("url") diff --git a/gen/adsensehost4d1-cli/Cargo.toml b/gen/adsensehost4d1-cli/Cargo.toml index c24106c3d9..ab9453bb48 100644 --- a/gen/adsensehost4d1-cli/Cargo.toml +++ b/gen/adsensehost4d1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adsensehost4d1-cli" -version = "0.3.6+20160907" +version = "1.0.0+20160907" authors = ["Sebastian Thiel "] description = "A complete library to interact with AdSense Host (protocol v4.1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/adsensehost4d1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-adsensehost4d1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-adsensehost4d1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-adsensehost4d1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-adsensehost4d1] path = "../adsensehost4d1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/adsensehost4d1-cli/README.md b/gen/adsensehost4d1-cli/README.md index 225d1e601d..49a485c094 100644 --- a/gen/adsensehost4d1-cli/README.md +++ b/gen/adsensehost4d1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *AdSense Host* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/adsensehost4d1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/adsensehost4d1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/adsensehost4d1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/adsensehost4d1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/adsensehost4d1-cli). # Usage -This documentation was generated from the *AdSense Host* API at revision *20160907*. The CLI is at version *0.3.6*. +This documentation was generated from the *AdSense Host* API at revision *20160907*. The CLI is at version *1.0.0*. ```bash adsensehost4d1 [options] diff --git a/gen/adsensehost4d1-cli/mkdocs.yml b/gen/adsensehost4d1-cli/mkdocs.yml index 78a0807f6b..5a6253b822 100644 --- a/gen/adsensehost4d1-cli/mkdocs.yml +++ b/gen/adsensehost4d1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: AdSense Host v0.3.6+20160907 +site_name: AdSense Host v1.0.0+20160907 site_url: http://byron.github.io/google-apis-rs/google-adsensehost4d1-cli site_description: Write integrating applications with bcore diff --git a/gen/adsensehost4d1-cli/src/main.rs b/gen/adsensehost4d1-cli/src/main.rs index 9360dc3cba..9115dda159 100644 --- a/gen/adsensehost4d1-cli/src/main.rs +++ b/gen/adsensehost4d1-cli/src/main.rs @@ -2761,7 +2761,7 @@ fn main() { let mut app = App::new("adsensehost4d1") .author("Sebastian Thiel ") - .version("0.3.6+20160907") + .version("1.0.0+20160907") .about("Generates performance reports, generates ad codes, and provides publisher management capabilities for AdSense Hosts.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_adsensehost4d1_cli") .arg(Arg::with_name("url") diff --git a/gen/analytics3-cli/Cargo.toml b/gen/analytics3-cli/Cargo.toml index 3c5aad5b39..debcbe97f6 100644 --- a/gen/analytics3-cli/Cargo.toml +++ b/gen/analytics3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-analytics3-cli" -version = "0.3.6+20160805" +version = "1.0.0+20160805" authors = ["Sebastian Thiel "] description = "A complete library to interact with analytics (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/analytics3-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-analytics3/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-analytics3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-analytics3/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-analytics3] path = "../analytics3" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/analytics3-cli/README.md b/gen/analytics3-cli/README.md index faa48f3cb0..c10102feec 100644 --- a/gen/analytics3-cli/README.md +++ b/gen/analytics3-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *analytics* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/analytics3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/analytics3.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/analytics3.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/analytics3.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/analytics3-cli). # Usage -This documentation was generated from the *analytics* API at revision *20160805*. The CLI is at version *0.3.6*. +This documentation was generated from the *analytics* API at revision *20160805*. The CLI is at version *1.0.0*. ```bash analytics3 [options] diff --git a/gen/analytics3-cli/mkdocs.yml b/gen/analytics3-cli/mkdocs.yml index cba0132e25..66480de5be 100644 --- a/gen/analytics3-cli/mkdocs.yml +++ b/gen/analytics3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: analytics v0.3.6+20160805 +site_name: analytics v1.0.0+20160805 site_url: http://byron.github.io/google-apis-rs/google-analytics3-cli site_description: Write integrating applications with bcore diff --git a/gen/analytics3-cli/src/main.rs b/gen/analytics3-cli/src/main.rs index b4d83cae08..b70445dfb8 100644 --- a/gen/analytics3-cli/src/main.rs +++ b/gen/analytics3-cli/src/main.rs @@ -9946,7 +9946,7 @@ fn main() { let mut app = App::new("analytics3") .author("Sebastian Thiel ") - .version("0.3.6+20160805") + .version("1.0.0+20160805") .about("Views and manages your Google Analytics data.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_analytics3_cli") .arg(Arg::with_name("url") diff --git a/gen/androidenterprise1-cli/Cargo.toml b/gen/androidenterprise1-cli/Cargo.toml index 668965e024..b3678ad471 100644 --- a/gen/androidenterprise1-cli/Cargo.toml +++ b/gen/androidenterprise1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-androidenterprise1-cli" -version = "0.3.6+20160831" +version = "1.0.0+20160831" authors = ["Sebastian Thiel "] description = "A complete library to interact with Android Enterprise (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/androidenterprise1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-androidenterprise1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-androidenterprise1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-androidenterprise1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-androidenterprise1] path = "../androidenterprise1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/androidenterprise1-cli/README.md b/gen/androidenterprise1-cli/README.md index a493c71405..f80477b4ca 100644 --- a/gen/androidenterprise1-cli/README.md +++ b/gen/androidenterprise1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Android Enterprise* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/androidenterprise1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/androidenterprise1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/androidenterprise1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/androidenterprise1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/androidenterprise1-cli). # Usage -This documentation was generated from the *Android Enterprise* API at revision *20160831*. The CLI is at version *0.3.6*. +This documentation was generated from the *Android Enterprise* API at revision *20160831*. The CLI is at version *1.0.0*. ```bash androidenterprise1 [options] diff --git a/gen/androidenterprise1-cli/mkdocs.yml b/gen/androidenterprise1-cli/mkdocs.yml index c326ef3c52..624f798b88 100644 --- a/gen/androidenterprise1-cli/mkdocs.yml +++ b/gen/androidenterprise1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Android Enterprise v0.3.6+20160831 +site_name: Android Enterprise v1.0.0+20160831 site_url: http://byron.github.io/google-apis-rs/google-androidenterprise1-cli site_description: Write integrating applications with bcore diff --git a/gen/androidenterprise1-cli/src/main.rs b/gen/androidenterprise1-cli/src/main.rs index e7da9d9fcc..d4b460a374 100644 --- a/gen/androidenterprise1-cli/src/main.rs +++ b/gen/androidenterprise1-cli/src/main.rs @@ -8825,7 +8825,7 @@ fn main() { let mut app = App::new("androidenterprise1") .author("Sebastian Thiel ") - .version("0.3.6+20160831") + .version("1.0.0+20160831") .about("Manages the deployment of apps to Android for Work users.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli") .arg(Arg::with_name("url") diff --git a/gen/androidpublisher2-cli/Cargo.toml b/gen/androidpublisher2-cli/Cargo.toml index b261da26af..5e4f392624 100644 --- a/gen/androidpublisher2-cli/Cargo.toml +++ b/gen/androidpublisher2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-androidpublisher2-cli" -version = "0.3.6+20160817" +version = "1.0.0+20160817" authors = ["Sebastian Thiel "] description = "A complete library to interact with Android Publisher (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/androidpublisher2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-androidpublisher2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-androidpublisher2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-androidpublisher2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-androidpublisher2] path = "../androidpublisher2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/androidpublisher2-cli/README.md b/gen/androidpublisher2-cli/README.md index d31497757a..510119bb83 100644 --- a/gen/androidpublisher2-cli/README.md +++ b/gen/androidpublisher2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Android Publisher* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/androidpublisher2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/androidpublisher2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/androidpublisher2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/androidpublisher2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/androidpublisher2-cli). # Usage -This documentation was generated from the *Android Publisher* API at revision *20160817*. The CLI is at version *0.3.6*. +This documentation was generated from the *Android Publisher* API at revision *20160817*. The CLI is at version *1.0.0*. ```bash androidpublisher2 [options] diff --git a/gen/androidpublisher2-cli/mkdocs.yml b/gen/androidpublisher2-cli/mkdocs.yml index e65c73859d..a0fa9e78d4 100644 --- a/gen/androidpublisher2-cli/mkdocs.yml +++ b/gen/androidpublisher2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Android Publisher v0.3.6+20160817 +site_name: Android Publisher v1.0.0+20160817 site_url: http://byron.github.io/google-apis-rs/google-androidpublisher2-cli site_description: Write integrating applications with bcore diff --git a/gen/androidpublisher2-cli/src/main.rs b/gen/androidpublisher2-cli/src/main.rs index 5de1383890..24063850ba 100644 --- a/gen/androidpublisher2-cli/src/main.rs +++ b/gen/androidpublisher2-cli/src/main.rs @@ -5769,7 +5769,7 @@ fn main() { let mut app = App::new("androidpublisher2") .author("Sebastian Thiel ") - .version("0.3.6+20160817") + .version("1.0.0+20160817") .about("Lets Android application developers access their Google Play accounts.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_androidpublisher2_cli") .arg(Arg::with_name("url") diff --git a/gen/appengine1-cli/Cargo.toml b/gen/appengine1-cli/Cargo.toml index 9ef3b1690e..f3fb9274d3 100644 --- a/gen/appengine1-cli/Cargo.toml +++ b/gen/appengine1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appengine1-cli" -version = "0.3.6+20160802" +version = "1.0.0+20160802" authors = ["Sebastian Thiel "] description = "A complete library to interact with appengine (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appengine1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-appengine1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-appengine1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-appengine1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-appengine1] path = "../appengine1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/appengine1-cli/README.md b/gen/appengine1-cli/README.md index 21973d7aed..d801f284f9 100644 --- a/gen/appengine1-cli/README.md +++ b/gen/appengine1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *appengine* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/appengine1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/appengine1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/appengine1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/appengine1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/appengine1-cli). # Usage -This documentation was generated from the *appengine* API at revision *20160802*. The CLI is at version *0.3.6*. +This documentation was generated from the *appengine* API at revision *20160802*. The CLI is at version *1.0.0*. ```bash appengine1 [options] diff --git a/gen/appengine1-cli/mkdocs.yml b/gen/appengine1-cli/mkdocs.yml index 2a81e86024..fa6757bfc5 100644 --- a/gen/appengine1-cli/mkdocs.yml +++ b/gen/appengine1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: appengine v0.3.6+20160802 +site_name: appengine v1.0.0+20160802 site_url: http://byron.github.io/google-apis-rs/google-appengine1-cli site_description: Write integrating applications with bcore diff --git a/gen/appengine1-cli/src/main.rs b/gen/appengine1-cli/src/main.rs index 8c70dd2f2b..30c1d798d0 100644 --- a/gen/appengine1-cli/src/main.rs +++ b/gen/appengine1-cli/src/main.rs @@ -2133,7 +2133,7 @@ fn main() { let mut app = App::new("appengine1") .author("Sebastian Thiel ") - .version("0.3.6+20160802") + .version("1.0.0+20160802") .about("Provisions and manages App Engine applications.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_appengine1_cli") .arg(Arg::with_name("url") diff --git a/gen/appengine1_beta4-cli/Cargo.toml b/gen/appengine1_beta4-cli/Cargo.toml index 43fb4c7d6c..798f3d9385 100644 --- a/gen/appengine1_beta4-cli/Cargo.toml +++ b/gen/appengine1_beta4-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appengine1_beta4-cli" -version = "0.3.6+20160802" +version = "1.0.0+20160802" authors = ["Sebastian Thiel "] description = "A complete library to interact with appengine (protocol v1beta4)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appengine1_beta4-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-appengine1_beta4/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-appengine1_beta4/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-appengine1_beta4/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-appengine1_beta4] path = "../appengine1_beta4" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/appengine1_beta4-cli/README.md b/gen/appengine1_beta4-cli/README.md index 9093ef5144..2b8cf38194 100644 --- a/gen/appengine1_beta4-cli/README.md +++ b/gen/appengine1_beta4-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *appengine* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/appengine1-beta4.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/appengine1-beta4.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/appengine1-beta4.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/appengine1-beta4.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/appengine1_beta4-cli). # Usage -This documentation was generated from the *appengine* API at revision *20160802*. The CLI is at version *0.3.6*. +This documentation was generated from the *appengine* API at revision *20160802*. The CLI is at version *1.0.0*. ```bash appengine1-beta4 [options] diff --git a/gen/appengine1_beta4-cli/mkdocs.yml b/gen/appengine1_beta4-cli/mkdocs.yml index 3791b22c21..04d14362d9 100644 --- a/gen/appengine1_beta4-cli/mkdocs.yml +++ b/gen/appengine1_beta4-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: appengine v0.3.6+20160802 +site_name: appengine v1.0.0+20160802 site_url: http://byron.github.io/google-apis-rs/google-appengine1_beta4-cli site_description: Write integrating applications with bcore diff --git a/gen/appengine1_beta4-cli/src/main.rs b/gen/appengine1_beta4-cli/src/main.rs index e71987fc30..1daef08f7d 100644 --- a/gen/appengine1_beta4-cli/src/main.rs +++ b/gen/appengine1_beta4-cli/src/main.rs @@ -2131,7 +2131,7 @@ fn main() { let mut app = App::new("appengine1-beta4") .author("Sebastian Thiel ") - .version("0.3.6+20160802") + .version("1.0.0+20160802") .about("Provisions and manages App Engine applications.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli") .arg(Arg::with_name("url") diff --git a/gen/appengine1_beta5-cli/Cargo.toml b/gen/appengine1_beta5-cli/Cargo.toml index 3e2c54f942..b3a27ac668 100644 --- a/gen/appengine1_beta5-cli/Cargo.toml +++ b/gen/appengine1_beta5-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appengine1_beta5-cli" -version = "0.3.6+20160802" +version = "1.0.0+20160802" authors = ["Sebastian Thiel "] description = "A complete library to interact with appengine (protocol v1beta5)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appengine1_beta5-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-appengine1_beta5/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-appengine1_beta5/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-appengine1_beta5/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-appengine1_beta5] path = "../appengine1_beta5" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/appengine1_beta5-cli/README.md b/gen/appengine1_beta5-cli/README.md index bca2711ddd..1bf97455df 100644 --- a/gen/appengine1_beta5-cli/README.md +++ b/gen/appengine1_beta5-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *appengine* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/appengine1-beta5.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/appengine1-beta5.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/appengine1-beta5.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/appengine1-beta5.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/appengine1_beta5-cli). # Usage -This documentation was generated from the *appengine* API at revision *20160802*. The CLI is at version *0.3.6*. +This documentation was generated from the *appengine* API at revision *20160802*. The CLI is at version *1.0.0*. ```bash appengine1-beta5 [options] diff --git a/gen/appengine1_beta5-cli/mkdocs.yml b/gen/appengine1_beta5-cli/mkdocs.yml index c5705f200e..ac63d20893 100644 --- a/gen/appengine1_beta5-cli/mkdocs.yml +++ b/gen/appengine1_beta5-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: appengine v0.3.6+20160802 +site_name: appengine v1.0.0+20160802 site_url: http://byron.github.io/google-apis-rs/google-appengine1_beta5-cli site_description: Write integrating applications with bcore diff --git a/gen/appengine1_beta5-cli/src/main.rs b/gen/appengine1_beta5-cli/src/main.rs index 2a62efa62d..953e67e10d 100644 --- a/gen/appengine1_beta5-cli/src/main.rs +++ b/gen/appengine1_beta5-cli/src/main.rs @@ -2133,7 +2133,7 @@ fn main() { let mut app = App::new("appengine1-beta5") .author("Sebastian Thiel ") - .version("0.3.6+20160802") + .version("1.0.0+20160802") .about("Provisions and manages App Engine applications.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli") .arg(Arg::with_name("url") diff --git a/gen/appsactivity1-cli/Cargo.toml b/gen/appsactivity1-cli/Cargo.toml index f6862f0927..cf8d4a7216 100644 --- a/gen/appsactivity1-cli/Cargo.toml +++ b/gen/appsactivity1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appsactivity1-cli" -version = "0.3.6+20160805" +version = "1.0.0+20160805" authors = ["Sebastian Thiel "] description = "A complete library to interact with appsactivity (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appsactivity1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-appsactivity1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-appsactivity1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-appsactivity1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-appsactivity1] path = "../appsactivity1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/appsactivity1-cli/README.md b/gen/appsactivity1-cli/README.md index 9c70becf02..401aa2acc3 100644 --- a/gen/appsactivity1-cli/README.md +++ b/gen/appsactivity1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *appsactivity* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/appsactivity1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/appsactivity1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/appsactivity1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/appsactivity1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/appsactivity1-cli). # Usage -This documentation was generated from the *appsactivity* API at revision *20160805*. The CLI is at version *0.3.6*. +This documentation was generated from the *appsactivity* API at revision *20160805*. The CLI is at version *1.0.0*. ```bash appsactivity1 [options] diff --git a/gen/appsactivity1-cli/mkdocs.yml b/gen/appsactivity1-cli/mkdocs.yml index 0e01a2a38a..9eab6b4158 100644 --- a/gen/appsactivity1-cli/mkdocs.yml +++ b/gen/appsactivity1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: appsactivity v0.3.6+20160805 +site_name: appsactivity v1.0.0+20160805 site_url: http://byron.github.io/google-apis-rs/google-appsactivity1-cli site_description: Write integrating applications with bcore diff --git a/gen/appsactivity1-cli/src/main.rs b/gen/appsactivity1-cli/src/main.rs index fc1f358601..846b066910 100644 --- a/gen/appsactivity1-cli/src/main.rs +++ b/gen/appsactivity1-cli/src/main.rs @@ -240,7 +240,7 @@ fn main() { let mut app = App::new("appsactivity1") .author("Sebastian Thiel ") - .version("0.3.6+20160805") + .version("1.0.0+20160805") .about("Provides a historical view of activity.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_appsactivity1_cli") .arg(Arg::with_name("url") diff --git a/gen/appstate1-cli/Cargo.toml b/gen/appstate1-cli/Cargo.toml index bca6dd4416..92cb73d8bc 100644 --- a/gen/appstate1-cli/Cargo.toml +++ b/gen/appstate1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appstate1-cli" -version = "0.3.6+20160901" +version = "1.0.0+20160901" authors = ["Sebastian Thiel "] description = "A complete library to interact with App State (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appstate1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-appstate1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-appstate1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-appstate1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-appstate1] path = "../appstate1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/appstate1-cli/README.md b/gen/appstate1-cli/README.md index b2e7214827..cee0bdc026 100644 --- a/gen/appstate1-cli/README.md +++ b/gen/appstate1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *App State* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/appstate1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/appstate1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/appstate1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/appstate1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/appstate1-cli). # Usage -This documentation was generated from the *App State* API at revision *20160901*. The CLI is at version *0.3.6*. +This documentation was generated from the *App State* API at revision *20160901*. The CLI is at version *1.0.0*. ```bash appstate1 [options] diff --git a/gen/appstate1-cli/mkdocs.yml b/gen/appstate1-cli/mkdocs.yml index 1f9306f105..f638939dce 100644 --- a/gen/appstate1-cli/mkdocs.yml +++ b/gen/appstate1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: App State v0.3.6+20160901 +site_name: App State v1.0.0+20160901 site_url: http://byron.github.io/google-apis-rs/google-appstate1-cli site_description: Write integrating applications with bcore diff --git a/gen/appstate1-cli/src/main.rs b/gen/appstate1-cli/src/main.rs index 78f775a2c9..d1194ef232 100644 --- a/gen/appstate1-cli/src/main.rs +++ b/gen/appstate1-cli/src/main.rs @@ -568,7 +568,7 @@ fn main() { let mut app = App::new("appstate1") .author("Sebastian Thiel ") - .version("0.3.6+20160901") + .version("1.0.0+20160901") .about("The Google App State API.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_appstate1_cli") .arg(Arg::with_name("url") diff --git a/gen/autoscaler1_beta2-cli/Cargo.toml b/gen/autoscaler1_beta2-cli/Cargo.toml index 175a01d457..5870e5a6a1 100644 --- a/gen/autoscaler1_beta2-cli/Cargo.toml +++ b/gen/autoscaler1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-autoscaler1_beta2-cli" -version = "0.3.6+20150629" +version = "1.0.0+20150629" authors = ["Sebastian Thiel "] description = "A complete library to interact with autoscaler (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/autoscaler1_beta2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-autoscaler1_beta2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-autoscaler1_beta2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-autoscaler1_beta2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-autoscaler1_beta2] path = "../autoscaler1_beta2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/autoscaler1_beta2-cli/README.md b/gen/autoscaler1_beta2-cli/README.md index e246caed00..b523d9c800 100644 --- a/gen/autoscaler1_beta2-cli/README.md +++ b/gen/autoscaler1_beta2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *autoscaler* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/autoscaler1-beta2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/autoscaler1-beta2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/autoscaler1-beta2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/autoscaler1-beta2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/autoscaler1_beta2-cli). # Usage -This documentation was generated from the *autoscaler* API at revision *20150629*. The CLI is at version *0.3.6*. +This documentation was generated from the *autoscaler* API at revision *20150629*. The CLI is at version *1.0.0*. ```bash autoscaler1-beta2 [options] diff --git a/gen/autoscaler1_beta2-cli/mkdocs.yml b/gen/autoscaler1_beta2-cli/mkdocs.yml index ecdec0daea..d88a453e04 100644 --- a/gen/autoscaler1_beta2-cli/mkdocs.yml +++ b/gen/autoscaler1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: autoscaler v0.3.6+20150629 +site_name: autoscaler v1.0.0+20150629 site_url: http://byron.github.io/google-apis-rs/google-autoscaler1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/autoscaler1_beta2-cli/src/main.rs b/gen/autoscaler1_beta2-cli/src/main.rs index 480073f23d..5191a31f12 100644 --- a/gen/autoscaler1_beta2-cli/src/main.rs +++ b/gen/autoscaler1_beta2-cli/src/main.rs @@ -1195,7 +1195,7 @@ fn main() { let mut app = App::new("autoscaler1-beta2") .author("Sebastian Thiel ") - .version("0.3.6+20150629") + .version("1.0.0+20150629") .about("The Google Compute Engine Autoscaler API provides autoscaling for groups of Cloud VMs.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_autoscaler1_beta2_cli") .arg(Arg::with_name("url") diff --git a/gen/bigquery2-cli/Cargo.toml b/gen/bigquery2-cli/Cargo.toml index fdab30a286..41143c2984 100644 --- a/gen/bigquery2-cli/Cargo.toml +++ b/gen/bigquery2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-bigquery2-cli" -version = "0.3.6+20160903" +version = "1.0.0+20160903" authors = ["Sebastian Thiel "] description = "A complete library to interact with bigquery (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/bigquery2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-bigquery2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-bigquery2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-bigquery2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-bigquery2] path = "../bigquery2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/bigquery2-cli/README.md b/gen/bigquery2-cli/README.md index a3971f3f73..a06b3cb7cc 100644 --- a/gen/bigquery2-cli/README.md +++ b/gen/bigquery2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *bigquery* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/bigquery2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/bigquery2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/bigquery2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/bigquery2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/bigquery2-cli). # Usage -This documentation was generated from the *bigquery* API at revision *20160903*. The CLI is at version *0.3.6*. +This documentation was generated from the *bigquery* API at revision *20160903*. The CLI is at version *1.0.0*. ```bash bigquery2 [options] diff --git a/gen/bigquery2-cli/mkdocs.yml b/gen/bigquery2-cli/mkdocs.yml index b6c27b4b41..17a377422d 100644 --- a/gen/bigquery2-cli/mkdocs.yml +++ b/gen/bigquery2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: bigquery v0.3.6+20160903 +site_name: bigquery v1.0.0+20160903 site_url: http://byron.github.io/google-apis-rs/google-bigquery2-cli site_description: Write integrating applications with bcore diff --git a/gen/bigquery2-cli/src/main.rs b/gen/bigquery2-cli/src/main.rs index 9608b686cc..11be6f8cbb 100644 --- a/gen/bigquery2-cli/src/main.rs +++ b/gen/bigquery2-cli/src/main.rs @@ -2576,7 +2576,7 @@ fn main() { let mut app = App::new("bigquery2") .author("Sebastian Thiel ") - .version("0.3.6+20160903") + .version("1.0.0+20160903") .about("A data platform for customers to create, manage, share and query data.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_bigquery2_cli") .arg(Arg::with_name("url") diff --git a/gen/blogger3-cli/Cargo.toml b/gen/blogger3-cli/Cargo.toml index 5f00470cd6..bd0e72926d 100644 --- a/gen/blogger3-cli/Cargo.toml +++ b/gen/blogger3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-blogger3-cli" -version = "0.3.6+20150422" +version = "1.0.0+20150422" authors = ["Sebastian Thiel "] description = "A complete library to interact with blogger (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/blogger3-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-blogger3/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-blogger3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-blogger3/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-blogger3] path = "../blogger3" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/blogger3-cli/README.md b/gen/blogger3-cli/README.md index f228ab2d3c..2e8bcde4de 100644 --- a/gen/blogger3-cli/README.md +++ b/gen/blogger3-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *blogger* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/blogger3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/blogger3.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/blogger3.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/blogger3.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/blogger3-cli). # Usage -This documentation was generated from the *blogger* API at revision *20150422*. The CLI is at version *0.3.6*. +This documentation was generated from the *blogger* API at revision *20150422*. The CLI is at version *1.0.0*. ```bash blogger3 [options] diff --git a/gen/blogger3-cli/mkdocs.yml b/gen/blogger3-cli/mkdocs.yml index abc617be5d..624ef5aecb 100644 --- a/gen/blogger3-cli/mkdocs.yml +++ b/gen/blogger3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: blogger v0.3.6+20150422 +site_name: blogger v1.0.0+20150422 site_url: http://byron.github.io/google-apis-rs/google-blogger3-cli site_description: Write integrating applications with bcore diff --git a/gen/blogger3-cli/src/main.rs b/gen/blogger3-cli/src/main.rs index cc18efe0ea..a6dd03633e 100644 --- a/gen/blogger3-cli/src/main.rs +++ b/gen/blogger3-cli/src/main.rs @@ -3496,7 +3496,7 @@ fn main() { let mut app = App::new("blogger3") .author("Sebastian Thiel ") - .version("0.3.6+20150422") + .version("1.0.0+20150422") .about("API for access to the data within Blogger.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_blogger3_cli") .arg(Arg::with_name("url") diff --git a/gen/books1-cli/Cargo.toml b/gen/books1-cli/Cargo.toml index c4e9ffbcdd..6fa0840fdb 100644 --- a/gen/books1-cli/Cargo.toml +++ b/gen/books1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-books1-cli" -version = "0.3.6+20160823" +version = "1.0.0+20160823" authors = ["Sebastian Thiel "] description = "A complete library to interact with books (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/books1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-books1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-books1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-books1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-books1] path = "../books1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/books1-cli/README.md b/gen/books1-cli/README.md index ca4c48b8fa..66c0bf947f 100644 --- a/gen/books1-cli/README.md +++ b/gen/books1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *books* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/books1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/books1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/books1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/books1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/books1-cli). # Usage -This documentation was generated from the *books* API at revision *20160823*. The CLI is at version *0.3.6*. +This documentation was generated from the *books* API at revision *20160823*. The CLI is at version *1.0.0*. ```bash books1 [options] diff --git a/gen/books1-cli/mkdocs.yml b/gen/books1-cli/mkdocs.yml index efbbaf9d38..e3aad683d7 100644 --- a/gen/books1-cli/mkdocs.yml +++ b/gen/books1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: books v0.3.6+20160823 +site_name: books v1.0.0+20160823 site_url: http://byron.github.io/google-apis-rs/google-books1-cli site_description: Write integrating applications with bcore diff --git a/gen/books1-cli/src/main.rs b/gen/books1-cli/src/main.rs index 4ecb7b04ee..975524ea20 100644 --- a/gen/books1-cli/src/main.rs +++ b/gen/books1-cli/src/main.rs @@ -4701,7 +4701,7 @@ fn main() { let mut app = App::new("books1") .author("Sebastian Thiel ") - .version("0.3.6+20160823") + .version("1.0.0+20160823") .about("Searches for books and manages your Google Books library.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_books1_cli") .arg(Arg::with_name("url") diff --git a/gen/calendar3-cli/Cargo.toml b/gen/calendar3-cli/Cargo.toml index 8505f6ec16..195a1af8a6 100644 --- a/gen/calendar3-cli/Cargo.toml +++ b/gen/calendar3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-calendar3-cli" -version = "0.3.6+20160830" +version = "1.0.0+20160830" authors = ["Sebastian Thiel "] description = "A complete library to interact with calendar (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/calendar3-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-calendar3/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-calendar3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-calendar3/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-calendar3] path = "../calendar3" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/calendar3-cli/README.md b/gen/calendar3-cli/README.md index 466ead93e6..9f8b0a9075 100644 --- a/gen/calendar3-cli/README.md +++ b/gen/calendar3-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *calendar* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/calendar3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/calendar3.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/calendar3.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/calendar3.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/calendar3-cli). # Usage -This documentation was generated from the *calendar* API at revision *20160830*. The CLI is at version *0.3.6*. +This documentation was generated from the *calendar* API at revision *20160830*. The CLI is at version *1.0.0*. ```bash calendar3 [options] diff --git a/gen/calendar3-cli/mkdocs.yml b/gen/calendar3-cli/mkdocs.yml index e8ba32e892..6dc6cd0d70 100644 --- a/gen/calendar3-cli/mkdocs.yml +++ b/gen/calendar3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: calendar v0.3.6+20160830 +site_name: calendar v1.0.0+20160830 site_url: http://byron.github.io/google-apis-rs/google-calendar3-cli site_description: Write integrating applications with bcore diff --git a/gen/calendar3-cli/src/main.rs b/gen/calendar3-cli/src/main.rs index 3fd099bf64..01baf777c5 100644 --- a/gen/calendar3-cli/src/main.rs +++ b/gen/calendar3-cli/src/main.rs @@ -4385,7 +4385,7 @@ fn main() { let mut app = App::new("calendar3") .author("Sebastian Thiel ") - .version("0.3.6+20160830") + .version("1.0.0+20160830") .about("Manipulates events and other calendar data.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_calendar3_cli") .arg(Arg::with_name("url") diff --git a/gen/civicinfo2-cli/Cargo.toml b/gen/civicinfo2-cli/Cargo.toml index 3fcd8331b3..b1c10612ad 100644 --- a/gen/civicinfo2-cli/Cargo.toml +++ b/gen/civicinfo2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-civicinfo2-cli" -version = "0.3.6+20160823" +version = "1.0.0+20160823" authors = ["Sebastian Thiel "] description = "A complete library to interact with Civic Info (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/civicinfo2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-civicinfo2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-civicinfo2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-civicinfo2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-civicinfo2] path = "../civicinfo2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/civicinfo2-cli/README.md b/gen/civicinfo2-cli/README.md index 65283cc58d..f126652f53 100644 --- a/gen/civicinfo2-cli/README.md +++ b/gen/civicinfo2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Civic Info* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/civicinfo2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/civicinfo2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/civicinfo2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/civicinfo2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/civicinfo2-cli). # Usage -This documentation was generated from the *Civic Info* API at revision *20160823*. The CLI is at version *0.3.6*. +This documentation was generated from the *Civic Info* API at revision *20160823*. The CLI is at version *1.0.0*. ```bash civicinfo2 [options] diff --git a/gen/civicinfo2-cli/mkdocs.yml b/gen/civicinfo2-cli/mkdocs.yml index 93c59370bb..f821fce33d 100644 --- a/gen/civicinfo2-cli/mkdocs.yml +++ b/gen/civicinfo2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Civic Info v0.3.6+20160823 +site_name: Civic Info v1.0.0+20160823 site_url: http://byron.github.io/google-apis-rs/google-civicinfo2-cli site_description: Write integrating applications with bcore diff --git a/gen/civicinfo2-cli/src/main.rs b/gen/civicinfo2-cli/src/main.rs index ce8d828750..0c273aa810 100644 --- a/gen/civicinfo2-cli/src/main.rs +++ b/gen/civicinfo2-cli/src/main.rs @@ -558,7 +558,7 @@ fn main() { let mut app = App::new("civicinfo2") .author("Sebastian Thiel ") - .version("0.3.6+20160823") + .version("1.0.0+20160823") .about("Provides polling places, early vote locations, contest data, election officials, and government representatives for U.S. residential addresses.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_civicinfo2_cli") .arg(Arg::with_name("folder") diff --git a/gen/classroom1-cli/Cargo.toml b/gen/classroom1-cli/Cargo.toml index 44b53bcd7d..8752a4932c 100644 --- a/gen/classroom1-cli/Cargo.toml +++ b/gen/classroom1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-classroom1-cli" -version = "0.3.6+20160816" +version = "1.0.0+20160816" authors = ["Sebastian Thiel "] description = "A complete library to interact with classroom (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/classroom1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-classroom1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-classroom1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-classroom1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-classroom1] path = "../classroom1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/classroom1-cli/README.md b/gen/classroom1-cli/README.md index 33628f44c6..fb27c4356d 100644 --- a/gen/classroom1-cli/README.md +++ b/gen/classroom1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *classroom* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/classroom1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/classroom1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/classroom1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/classroom1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/classroom1-cli). # Usage -This documentation was generated from the *classroom* API at revision *20160816*. The CLI is at version *0.3.6*. +This documentation was generated from the *classroom* API at revision *20160816*. The CLI is at version *1.0.0*. ```bash classroom1 [options] diff --git a/gen/classroom1-cli/mkdocs.yml b/gen/classroom1-cli/mkdocs.yml index 84b86a6e10..d203fd66ef 100644 --- a/gen/classroom1-cli/mkdocs.yml +++ b/gen/classroom1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: classroom v0.3.6+20160816 +site_name: classroom v1.0.0+20160816 site_url: http://byron.github.io/google-apis-rs/google-classroom1-cli site_description: Write integrating applications with bcore diff --git a/gen/classroom1-cli/src/main.rs b/gen/classroom1-cli/src/main.rs index 8f715765f5..f01df68b67 100644 --- a/gen/classroom1-cli/src/main.rs +++ b/gen/classroom1-cli/src/main.rs @@ -4154,7 +4154,7 @@ fn main() { let mut app = App::new("classroom1") .author("Sebastian Thiel ") - .version("0.3.6+20160816") + .version("1.0.0+20160816") .about("Manages classes, rosters, and invitations in Google Classroom.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_classroom1_cli") .arg(Arg::with_name("url") diff --git a/gen/cloudbilling1-cli/Cargo.toml b/gen/cloudbilling1-cli/Cargo.toml index f63d27852c..f0654ae8a4 100644 --- a/gen/cloudbilling1-cli/Cargo.toml +++ b/gen/cloudbilling1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudbilling1-cli" -version = "0.3.6+20151222" +version = "1.0.0+20151222" authors = ["Sebastian Thiel "] description = "A complete library to interact with cloudbilling (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudbilling1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-cloudbilling1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-cloudbilling1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudbilling1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudbilling1] path = "../cloudbilling1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/cloudbilling1-cli/README.md b/gen/cloudbilling1-cli/README.md index 1dcf952f90..ace18ad744 100644 --- a/gen/cloudbilling1-cli/README.md +++ b/gen/cloudbilling1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *cloudbilling* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/cloudbilling1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/cloudbilling1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/cloudbilling1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/cloudbilling1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudbilling1-cli). # Usage -This documentation was generated from the *cloudbilling* API at revision *20151222*. The CLI is at version *0.3.6*. +This documentation was generated from the *cloudbilling* API at revision *20151222*. The CLI is at version *1.0.0*. ```bash cloudbilling1 [options] diff --git a/gen/cloudbilling1-cli/mkdocs.yml b/gen/cloudbilling1-cli/mkdocs.yml index 34481b4b95..91fdf59152 100644 --- a/gen/cloudbilling1-cli/mkdocs.yml +++ b/gen/cloudbilling1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: cloudbilling v0.3.6+20151222 +site_name: cloudbilling v1.0.0+20151222 site_url: http://byron.github.io/google-apis-rs/google-cloudbilling1-cli site_description: Write integrating applications with bcore diff --git a/gen/cloudbilling1-cli/src/main.rs b/gen/cloudbilling1-cli/src/main.rs index 7ae22b220d..a1190af905 100644 --- a/gen/cloudbilling1-cli/src/main.rs +++ b/gen/cloudbilling1-cli/src/main.rs @@ -597,7 +597,7 @@ fn main() { let mut app = App::new("cloudbilling1") .author("Sebastian Thiel ") - .version("0.3.6+20151222") + .version("1.0.0+20151222") .about("Retrieves Google Developers Console billing accounts and associates them with projects.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_cloudbilling1_cli") .arg(Arg::with_name("url") diff --git a/gen/clouddebugger2-cli/Cargo.toml b/gen/clouddebugger2-cli/Cargo.toml index 092df93ebf..3fcba8606e 100644 --- a/gen/clouddebugger2-cli/Cargo.toml +++ b/gen/clouddebugger2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-clouddebugger2-cli" -version = "0.3.6+20160810" +version = "1.0.0+20160810" authors = ["Sebastian Thiel "] description = "A complete library to interact with Cloud Debugger (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/clouddebugger2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-clouddebugger2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-clouddebugger2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-clouddebugger2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-clouddebugger2] path = "../clouddebugger2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/clouddebugger2-cli/README.md b/gen/clouddebugger2-cli/README.md index 4d0cc3f79a..622edf0171 100644 --- a/gen/clouddebugger2-cli/README.md +++ b/gen/clouddebugger2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Cloud Debugger* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/clouddebugger2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/clouddebugger2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/clouddebugger2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/clouddebugger2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/clouddebugger2-cli). # Usage -This documentation was generated from the *Cloud Debugger* API at revision *20160810*. The CLI is at version *0.3.6*. +This documentation was generated from the *Cloud Debugger* API at revision *20160810*. The CLI is at version *1.0.0*. ```bash clouddebugger2 [options] diff --git a/gen/clouddebugger2-cli/mkdocs.yml b/gen/clouddebugger2-cli/mkdocs.yml index e9d0e1f6fd..7f761f6ef5 100644 --- a/gen/clouddebugger2-cli/mkdocs.yml +++ b/gen/clouddebugger2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Cloud Debugger v0.3.6+20160810 +site_name: Cloud Debugger v1.0.0+20160810 site_url: http://byron.github.io/google-apis-rs/google-clouddebugger2-cli site_description: Write integrating applications with bcore diff --git a/gen/clouddebugger2-cli/src/main.rs b/gen/clouddebugger2-cli/src/main.rs index def8ac7e2f..f9120c082f 100644 --- a/gen/clouddebugger2-cli/src/main.rs +++ b/gen/clouddebugger2-cli/src/main.rs @@ -992,7 +992,7 @@ fn main() { let mut app = App::new("clouddebugger2") .author("Sebastian Thiel ") - .version("0.3.6+20160810") + .version("1.0.0+20160810") .about("Examines the call stack and variables of a running application without stopping or slowing it down.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_clouddebugger2_cli") .arg(Arg::with_name("url") diff --git a/gen/cloudlatencytest2-cli/Cargo.toml b/gen/cloudlatencytest2-cli/Cargo.toml index 1dd6abb345..4ce205d02d 100644 --- a/gen/cloudlatencytest2-cli/Cargo.toml +++ b/gen/cloudlatencytest2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudlatencytest2-cli" -version = "0.3.6+20160309" +version = "1.0.0+20160309" authors = ["Sebastian Thiel "] description = "A complete library to interact with cloudlatencytest (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudlatencytest2-cli" @@ -20,15 +20,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-cloudlatencytest2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-cloudlatencytest2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudlatencytest2/with-serde-codegen"] [build-dependencies] @@ -37,6 +37,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudlatencytest2] path = "../cloudlatencytest2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/cloudlatencytest2-cli/README.md b/gen/cloudlatencytest2-cli/README.md index 8b278235e2..e50ce8b622 100644 --- a/gen/cloudlatencytest2-cli/README.md +++ b/gen/cloudlatencytest2-cli/README.md @@ -14,14 +14,14 @@ If data-structures are requested, these will be returned as pretty-printed JSON, You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/cloudlatencytest2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/cloudlatencytest2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/cloudlatencytest2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/cloudlatencytest2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudlatencytest2-cli). # Usage -This documentation was generated from the *cloudlatencytest* API at revision *20160309*. The CLI is at version *0.3.6*. +This documentation was generated from the *cloudlatencytest* API at revision *20160309*. The CLI is at version *1.0.0*. ```bash cloudlatencytest2 [options] diff --git a/gen/cloudlatencytest2-cli/mkdocs.yml b/gen/cloudlatencytest2-cli/mkdocs.yml index 1b62d524a2..8c720f9bc5 100644 --- a/gen/cloudlatencytest2-cli/mkdocs.yml +++ b/gen/cloudlatencytest2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: cloudlatencytest v0.3.6+20160309 +site_name: cloudlatencytest v1.0.0+20160309 site_url: http://byron.github.io/google-apis-rs/google-cloudlatencytest2-cli site_description: Write integrating applications with bcore diff --git a/gen/cloudlatencytest2-cli/src/main.rs b/gen/cloudlatencytest2-cli/src/main.rs index 3c01f9625a..53c3facea0 100644 --- a/gen/cloudlatencytest2-cli/src/main.rs +++ b/gen/cloudlatencytest2-cli/src/main.rs @@ -366,7 +366,7 @@ fn main() { let mut app = App::new("cloudlatencytest2") .author("Sebastian Thiel ") - .version("0.3.6+20160309") + .version("1.0.0+20160309") .about("Reports latency data.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_cloudlatencytest2_cli") .arg(Arg::with_name("url") diff --git a/gen/cloudmonitoring2_beta2-cli/Cargo.toml b/gen/cloudmonitoring2_beta2-cli/Cargo.toml index 720bcd59bf..b0f57faf56 100644 --- a/gen/cloudmonitoring2_beta2-cli/Cargo.toml +++ b/gen/cloudmonitoring2_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudmonitoring2_beta2-cli" -version = "0.3.6+20160718" +version = "1.0.0+20160718" authors = ["Sebastian Thiel "] description = "A complete library to interact with Cloud Monitoring (protocol v2beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudmonitoring2_beta2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-cloudmonitoring2_beta2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-cloudmonitoring2_beta2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudmonitoring2_beta2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudmonitoring2_beta2] path = "../cloudmonitoring2_beta2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/cloudmonitoring2_beta2-cli/README.md b/gen/cloudmonitoring2_beta2-cli/README.md index 1d0ad8a9ee..d4272c91c0 100644 --- a/gen/cloudmonitoring2_beta2-cli/README.md +++ b/gen/cloudmonitoring2_beta2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Cloud Monitoring* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/cloudmonitoring2-beta2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/cloudmonitoring2-beta2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/cloudmonitoring2-beta2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/cloudmonitoring2-beta2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudmonitoring2_beta2-cli). # Usage -This documentation was generated from the *Cloud Monitoring* API at revision *20160718*. The CLI is at version *0.3.6*. +This documentation was generated from the *Cloud Monitoring* API at revision *20160718*. The CLI is at version *1.0.0*. ```bash cloudmonitoring2-beta2 [options] diff --git a/gen/cloudmonitoring2_beta2-cli/mkdocs.yml b/gen/cloudmonitoring2_beta2-cli/mkdocs.yml index eccd51cac6..1d2255d96a 100644 --- a/gen/cloudmonitoring2_beta2-cli/mkdocs.yml +++ b/gen/cloudmonitoring2_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Cloud Monitoring v0.3.6+20160718 +site_name: Cloud Monitoring v1.0.0+20160718 site_url: http://byron.github.io/google-apis-rs/google-cloudmonitoring2_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/cloudmonitoring2_beta2-cli/src/main.rs b/gen/cloudmonitoring2_beta2-cli/src/main.rs index 5f96f3dd55..2a2863d77e 100644 --- a/gen/cloudmonitoring2_beta2-cli/src/main.rs +++ b/gen/cloudmonitoring2_beta2-cli/src/main.rs @@ -914,7 +914,7 @@ fn main() { let mut app = App::new("cloudmonitoring2-beta2") .author("Sebastian Thiel ") - .version("0.3.6+20160718") + .version("1.0.0+20160718") .about("Accesses Google Cloud Monitoring data.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_cloudmonitoring2_beta2_cli") .arg(Arg::with_name("url") diff --git a/gen/cloudresourcemanager1-cli/Cargo.toml b/gen/cloudresourcemanager1-cli/Cargo.toml index a0a139b86d..17545b142e 100644 --- a/gen/cloudresourcemanager1-cli/Cargo.toml +++ b/gen/cloudresourcemanager1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudresourcemanager1-cli" -version = "0.3.6+20160617" +version = "1.0.0+20160617" authors = ["Sebastian Thiel "] description = "A complete library to interact with Cloud Resource Manager (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudresourcemanager1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-cloudresourcemanager1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-cloudresourcemanager1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudresourcemanager1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudresourcemanager1] path = "../cloudresourcemanager1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/cloudresourcemanager1-cli/README.md b/gen/cloudresourcemanager1-cli/README.md index 1d713eba6a..b3044712bb 100644 --- a/gen/cloudresourcemanager1-cli/README.md +++ b/gen/cloudresourcemanager1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Cloud Resource Manager* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/cloudresourcemanager1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/cloudresourcemanager1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/cloudresourcemanager1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/cloudresourcemanager1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudresourcemanager1-cli). # Usage -This documentation was generated from the *Cloud Resource Manager* API at revision *20160617*. The CLI is at version *0.3.6*. +This documentation was generated from the *Cloud Resource Manager* API at revision *20160617*. The CLI is at version *1.0.0*. ```bash cloudresourcemanager1 [options] diff --git a/gen/cloudresourcemanager1-cli/mkdocs.yml b/gen/cloudresourcemanager1-cli/mkdocs.yml index fafd7631ce..2157d2ca7e 100644 --- a/gen/cloudresourcemanager1-cli/mkdocs.yml +++ b/gen/cloudresourcemanager1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Cloud Resource Manager v0.3.6+20160617 +site_name: Cloud Resource Manager v1.0.0+20160617 site_url: http://byron.github.io/google-apis-rs/google-cloudresourcemanager1-cli site_description: Write integrating applications with bcore diff --git a/gen/cloudresourcemanager1-cli/src/main.rs b/gen/cloudresourcemanager1-cli/src/main.rs index 785e59e848..151a5da40b 100644 --- a/gen/cloudresourcemanager1-cli/src/main.rs +++ b/gen/cloudresourcemanager1-cli/src/main.rs @@ -1060,7 +1060,7 @@ fn main() { let mut app = App::new("cloudresourcemanager1") .author("Sebastian Thiel ") - .version("0.3.6+20160617") + .version("1.0.0+20160617") .about("The Google Cloud Resource Manager API provides methods for creating, reading, and updating project metadata.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_cli") .arg(Arg::with_name("url") diff --git a/gen/cloudresourcemanager1_beta1-cli/Cargo.toml b/gen/cloudresourcemanager1_beta1-cli/Cargo.toml index 0c1f2702d6..811c9be048 100644 --- a/gen/cloudresourcemanager1_beta1-cli/Cargo.toml +++ b/gen/cloudresourcemanager1_beta1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudresourcemanager1_beta1-cli" -version = "0.3.6+20160617" +version = "1.0.0+20160617" authors = ["Sebastian Thiel "] description = "A complete library to interact with Cloud Resource Manager (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudresourcemanager1_beta1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-cloudresourcemanager1_beta1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-cloudresourcemanager1_beta1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudresourcemanager1_beta1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudresourcemanager1_beta1] path = "../cloudresourcemanager1_beta1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/cloudresourcemanager1_beta1-cli/README.md b/gen/cloudresourcemanager1_beta1-cli/README.md index a1f48ed24d..a7040d29c6 100644 --- a/gen/cloudresourcemanager1_beta1-cli/README.md +++ b/gen/cloudresourcemanager1_beta1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Cloud Resource Manager* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/cloudresourcemanager1-beta1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/cloudresourcemanager1-beta1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/cloudresourcemanager1-beta1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/cloudresourcemanager1-beta1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudresourcemanager1_beta1-cli). # Usage -This documentation was generated from the *Cloud Resource Manager* API at revision *20160617*. The CLI is at version *0.3.6*. +This documentation was generated from the *Cloud Resource Manager* API at revision *20160617*. The CLI is at version *1.0.0*. ```bash cloudresourcemanager1-beta1 [options] diff --git a/gen/cloudresourcemanager1_beta1-cli/mkdocs.yml b/gen/cloudresourcemanager1_beta1-cli/mkdocs.yml index 11fd85df64..664d6a56ee 100644 --- a/gen/cloudresourcemanager1_beta1-cli/mkdocs.yml +++ b/gen/cloudresourcemanager1_beta1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Cloud Resource Manager v0.3.6+20160617 +site_name: Cloud Resource Manager v1.0.0+20160617 site_url: http://byron.github.io/google-apis-rs/google-cloudresourcemanager1_beta1-cli site_description: Write integrating applications with bcore diff --git a/gen/cloudresourcemanager1_beta1-cli/src/main.rs b/gen/cloudresourcemanager1_beta1-cli/src/main.rs index 0c3e34f8b6..eb6be5cec0 100644 --- a/gen/cloudresourcemanager1_beta1-cli/src/main.rs +++ b/gen/cloudresourcemanager1_beta1-cli/src/main.rs @@ -1846,7 +1846,7 @@ fn main() { let mut app = App::new("cloudresourcemanager1-beta1") .author("Sebastian Thiel ") - .version("0.3.6+20160617") + .version("1.0.0+20160617") .about("The Google Cloud Resource Manager API provides methods for creating, reading, and updating project metadata.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli") .arg(Arg::with_name("url") diff --git a/gen/cloudtrace1-cli/Cargo.toml b/gen/cloudtrace1-cli/Cargo.toml index 6639efeab9..404c6429e4 100644 --- a/gen/cloudtrace1-cli/Cargo.toml +++ b/gen/cloudtrace1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudtrace1-cli" -version = "0.3.6+20160518" +version = "1.0.0+20160518" authors = ["Sebastian Thiel "] description = "A complete library to interact with Cloud Trace (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudtrace1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-cloudtrace1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-cloudtrace1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudtrace1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudtrace1] path = "../cloudtrace1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/cloudtrace1-cli/README.md b/gen/cloudtrace1-cli/README.md index db5341173e..172e7a0dc6 100644 --- a/gen/cloudtrace1-cli/README.md +++ b/gen/cloudtrace1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Cloud Trace* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/cloudtrace1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/cloudtrace1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/cloudtrace1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/cloudtrace1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudtrace1-cli). # Usage -This documentation was generated from the *Cloud Trace* API at revision *20160518*. The CLI is at version *0.3.6*. +This documentation was generated from the *Cloud Trace* API at revision *20160518*. The CLI is at version *1.0.0*. ```bash cloudtrace1 [options] diff --git a/gen/cloudtrace1-cli/mkdocs.yml b/gen/cloudtrace1-cli/mkdocs.yml index b0de8b0438..31df586342 100644 --- a/gen/cloudtrace1-cli/mkdocs.yml +++ b/gen/cloudtrace1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Cloud Trace v0.3.6+20160518 +site_name: Cloud Trace v1.0.0+20160518 site_url: http://byron.github.io/google-apis-rs/google-cloudtrace1-cli site_description: Write integrating applications with bcore diff --git a/gen/cloudtrace1-cli/src/main.rs b/gen/cloudtrace1-cli/src/main.rs index 8c14254b4d..d67a4f42f2 100644 --- a/gen/cloudtrace1-cli/src/main.rs +++ b/gen/cloudtrace1-cli/src/main.rs @@ -448,7 +448,7 @@ fn main() { let mut app = App::new("cloudtrace1") .author("Sebastian Thiel ") - .version("0.3.6+20160518") + .version("1.0.0+20160518") .about("Send and retrieve trace data from Google Cloud Trace. Data is generated and available by default for all App Engine applications. Data from other applications can be written to Cloud Trace for display, reporting, and analysis.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_cloudtrace1_cli") .arg(Arg::with_name("url") diff --git a/gen/clouduseraccountsvm_beta-cli/Cargo.toml b/gen/clouduseraccountsvm_beta-cli/Cargo.toml index 984a7cacf1..b2b7fa294c 100644 --- a/gen/clouduseraccountsvm_beta-cli/Cargo.toml +++ b/gen/clouduseraccountsvm_beta-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-clouduseraccountsvm_beta-cli" -version = "0.3.6+20160316" +version = "1.0.0+20160316" authors = ["Sebastian Thiel "] description = "A complete library to interact with Cloud User Accounts (protocol vm_beta)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/clouduseraccountsvm_beta-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-clouduseraccountsvm_beta/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-clouduseraccountsvm_beta/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-clouduseraccountsvm_beta/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-clouduseraccountsvm_beta] path = "../clouduseraccountsvm_beta" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/clouduseraccountsvm_beta-cli/README.md b/gen/clouduseraccountsvm_beta-cli/README.md index c23220d38d..329e4b0f03 100644 --- a/gen/clouduseraccountsvm_beta-cli/README.md +++ b/gen/clouduseraccountsvm_beta-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Cloud User Accounts* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/clouduseraccountsvm-beta.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/clouduseraccountsvm-beta.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/clouduseraccountsvm-beta.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/clouduseraccountsvm-beta.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/clouduseraccountsvm_beta-cli). # Usage -This documentation was generated from the *Cloud User Accounts* API at revision *20160316*. The CLI is at version *0.3.6*. +This documentation was generated from the *Cloud User Accounts* API at revision *20160316*. The CLI is at version *1.0.0*. ```bash clouduseraccountsvm-beta [options] diff --git a/gen/clouduseraccountsvm_beta-cli/mkdocs.yml b/gen/clouduseraccountsvm_beta-cli/mkdocs.yml index df30004b7f..67d9a4cd61 100644 --- a/gen/clouduseraccountsvm_beta-cli/mkdocs.yml +++ b/gen/clouduseraccountsvm_beta-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Cloud User Accounts v0.3.6+20160316 +site_name: Cloud User Accounts v1.0.0+20160316 site_url: http://byron.github.io/google-apis-rs/google-clouduseraccountsvm_beta-cli site_description: Write integrating applications with bcore diff --git a/gen/clouduseraccountsvm_beta-cli/src/main.rs b/gen/clouduseraccountsvm_beta-cli/src/main.rs index 8d029f2b9f..8d47323564 100644 --- a/gen/clouduseraccountsvm_beta-cli/src/main.rs +++ b/gen/clouduseraccountsvm_beta-cli/src/main.rs @@ -1839,7 +1839,7 @@ fn main() { let mut app = App::new("clouduseraccountsvm-beta") .author("Sebastian Thiel ") - .version("0.3.6+20160316") + .version("1.0.0+20160316") .about("Creates and manages users and groups for accessing Google Compute Engine virtual machines.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_clouduseraccountsvm_beta_cli") .arg(Arg::with_name("url") diff --git a/gen/compute1-cli/Cargo.toml b/gen/compute1-cli/Cargo.toml deleted file mode 100644 index 3ca82b201a..0000000000 --- a/gen/compute1-cli/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-compute1-cli" -version = "0.3.6+20160908" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with compute (protocol v1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/compute1-cli" -homepage = "https://developers.google.com/compute/docs/reference/latest/" -documentation = "http://byron.github.io/google-apis-rs/google_compute1_cli" -license = "MIT" -keywords = ["compute", "google", "cli"] - -[[bin]] -name = "compute1" - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.8" -serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } -strsim = "^0.5" -yup-hyper-mock = "^1.0" -clap = "^2.0" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-compute1/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-compute1/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.8", optional = true } - - -[dependencies.google-compute1] -path = "../compute1" -version = "0.1.15" -optional = true -default-features = false diff --git a/gen/compute1-cli/LICENSE.md b/gen/compute1-cli/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/compute1-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/compute1-cli/README.md b/gen/compute1-cli/README.md deleted file mode 100644 index ae54dc7a6e..0000000000 --- a/gen/compute1-cli/README.md +++ /dev/null @@ -1,372 +0,0 @@ - -The `compute1` command-line interface *(CLI)* allows to use most features of the *Google compute* service from the comfort of your terminal. - -By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's -capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. - -If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. - -Everything else about the *compute* API can be found at the -[official documentation site](https://developers.google.com/compute/docs/reference/latest/). - -# Downloads - -You can download the pre-compiled 64bit binaries for the following platforms: - -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/compute1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/compute1.tar.gz) - -Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/compute1-cli). - -# Usage - -This documentation was generated from the *compute* API at revision *20160908*. The CLI is at version *0.3.6*. - -```bash -compute1 [options] - addresses - aggregated-list [-p ]... [-o ] - delete
[-p ]... [-o ] - get
[-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - autoscalers - aggregated-list [-p ]... [-o ] - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - patch (-r )... [-p ]... [-o ] - update (-r )... [-p ]... [-o ] - backend-services - delete [-p ]... [-o ] - get [-p ]... [-o ] - get-health (-r )... [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - patch (-r )... [-p ]... [-o ] - update (-r )... [-p ]... [-o ] - disk-types - aggregated-list [-p ]... [-o ] - get [-p ]... [-o ] - list [-p ]... [-o ] - disks - aggregated-list [-p ]... [-o ] - create-snapshot (-r )... [-p ]... [-o ] - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - resize (-r )... [-p ]... [-o ] - firewalls - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - patch (-r )... [-p ]... [-o ] - update (-r )... [-p ]... [-o ] - forwarding-rules - aggregated-list [-p ]... [-o ] - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - set-target (-r )... [-p ]... [-o ] - global-addresses - delete
[-p ]... [-o ] - get
[-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - global-forwarding-rules - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - set-target (-r )... [-p ]... [-o ] - global-operations - aggregated-list [-p ]... [-o ] - delete [-p ]... - get [-p ]... [-o ] - list [-p ]... [-o ] - health-checks - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - patch (-r )... [-p ]... [-o ] - update (-r )... [-p ]... [-o ] - http-health-checks - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - patch (-r )... [-p ]... [-o ] - update (-r )... [-p ]... [-o ] - https-health-checks - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - patch (-r )... [-p ]... [-o ] - update (-r )... [-p ]... [-o ] - images - delete [-p ]... [-o ] - deprecate (-r )... [-p ]... [-o ] - get [-p ]... [-o ] - get-from-family [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - instance-group-managers - abandon-instances (-r )... [-p ]... [-o ] - aggregated-list [-p ]... [-o ] - delete [-p ]... [-o ] - delete-instances (-r )... [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - list-managed-instances [-p ]... [-o ] - recreate-instances (-r )... [-p ]... [-o ] - resize [-p ]... [-o ] - set-instance-template (-r )... [-p ]... [-o ] - set-target-pools (-r )... [-p ]... [-o ] - instance-groups - add-instances (-r )... [-p ]... [-o ] - aggregated-list [-p ]... [-o ] - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - list-instances (-r )... [-p ]... [-o ] - remove-instances (-r )... [-p ]... [-o ] - set-named-ports (-r )... [-p ]... [-o ] - instance-templates - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - instances - add-access-config (-r )... [-p ]... [-o ] - aggregated-list [-p ]... [-o ] - attach-disk (-r )... [-p ]... [-o ] - delete [-p ]... [-o ] - delete-access-config [-p ]... [-o ] - detach-disk [-p ]... [-o ] - get [-p ]... [-o ] - get-serial-port-output [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - reset [-p ]... [-o ] - set-disk-auto-delete [-p ]... [-o ] - set-machine-type (-r )... [-p ]... [-o ] - set-metadata (-r )... [-p ]... [-o ] - set-scheduling (-r )... [-p ]... [-o ] - set-tags (-r )... [-p ]... [-o ] - start [-p ]... [-o ] - start-with-encryption-key (-r )... [-p ]... [-o ] - stop [-p ]... [-o ] - licenses - get [-p ]... [-o ] - machine-types - aggregated-list [-p ]... [-o ] - get [-p ]... [-o ] - list [-p ]... [-o ] - networks - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - projects - get [-p ]... [-o ] - move-disk (-r )... [-p ]... [-o ] - move-instance (-r )... [-p ]... [-o ] - set-common-instance-metadata (-r )... [-p ]... [-o ] - set-usage-export-bucket (-r )... [-p ]... [-o ] - region-operations - delete [-p ]... - get [-p ]... [-o ] - list [-p ]... [-o ] - regions - get [-p ]... [-o ] - list [-p ]... [-o ] - routers - aggregated-list [-p ]... [-o ] - delete [-p ]... [-o ] - get [-p ]... [-o ] - get-router-status [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - patch (-r )... [-p ]... [-o ] - preview (-r )... [-p ]... [-o ] - update (-r )... [-p ]... [-o ] - routes - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - snapshots - delete [-p ]... [-o ] - get [-p ]... [-o ] - list [-p ]... [-o ] - ssl-certificates - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - subnetworks - aggregated-list [-p ]... [-o ] - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - target-http-proxies - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - set-url-map (-r )... [-p ]... [-o ] - target-https-proxies - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - set-ssl-certificates (-r )... [-p ]... [-o ] - set-url-map (-r )... [-p ]... [-o ] - target-instances - aggregated-list [-p ]... [-o ] - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - target-pools - add-health-check (-r )... [-p ]... [-o ] - add-instance (-r )... [-p ]... [-o ] - aggregated-list [-p ]... [-o ] - delete [-p ]... [-o ] - get [-p ]... [-o ] - get-health (-r )... [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - remove-health-check (-r )... [-p ]... [-o ] - remove-instance (-r )... [-p ]... [-o ] - set-backup (-r )... [-p ]... [-o ] - target-ssl-proxies - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - set-backend-service (-r )... [-p ]... [-o ] - set-proxy-header (-r )... [-p ]... [-o ] - set-ssl-certificates (-r )... [-p ]... [-o ] - target-vpn-gateways - aggregated-list [-p ]... [-o ] - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - url-maps - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - invalidate-cache (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - patch (-r )... [-p ]... [-o ] - update (-r )... [-p ]... [-o ] - validate (-r )... [-p ]... [-o ] - vpn-tunnels - aggregated-list [-p ]... [-o ] - delete [-p ]... [-o ] - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - zone-operations - delete [-p ]... - get [-p ]... [-o ] - list [-p ]... [-o ] - zones - get [-p ]... [-o ] - list [-p ]... [-o ] - compute1 --help - -Configuration: - [--scope ]... - Specify the authentication a method should be executed in. Each scope - requires the user to grant this application permission to use it. - If unset, it defaults to the shortest scope url for a particular method. - --config-dir - A directory into which we will store our persistent data. Defaults to - a user-writable directory that we will create during the first invocation. - [default: ~/.google-service-cli] - --debug - Output all server communication to standard error. `tx` and `rx` are placed - into the same stream. - --debug-auth - Output all communication related to authentication to standard error. `tx` - and `rx` are placed into the same stream. - -``` - -# Configuration - -The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `compute1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. - -More information about the various kinds of persistent data are given in the following paragraphs. - -# Authentication - -Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the -set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. - -If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a -method that is read-only, it will ask only for a read-only scope. -You may use the `--scope` flag to specify a scope directly. -All applicable scopes are documented in the respective method's CLI documentation. - -The first time a scope is used, the user is asked for permission. Follow the instructions given -by the CLI to grant permissions, or to decline. - -If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration -directory, e.g. `~/.google-service-cli/compute1-token-.json`. No manual management of these tokens -is necessary. - -To revoke granted authentication, please refer to the [official documentation][revoke-access]. - -# Application Secrets - -In order to allow any application to use Google services, it will need to be registered using the -[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it -one by one. Most APIs can be used for free and have a daily quota. - -To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI -comes with a default application secret that is configured accordingly. This also means that heavy usage -all around the world may deplete the daily quota. - -You can workaround this limitation by putting your own secrets file at this location: -`~/.google-service-cli/compute1-secret.json`, assuming that the required *compute* API -was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at -*APIs & auth -> Credentials -> Download JSON* and used as is. - -Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. - - -# Debugging - -Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know -what exactly led to a particular issue. This is done by allowing all client-server communication to be -output to standard error *as-is*. - -The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag -will cause all communication related to authentication to standard error. -If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the -issue at hand. - -You may consider redirecting standard error into a file for ease of use, e.g. `compute1 --debug [options] 2>debug.txt`. - - -[scopes]: https://developers.google.com/+/api/oauth#scopes -[revoke-access]: http://webapps.stackexchange.com/a/30849 -[google-dev-console]: https://console.developers.google.com/ -[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/compute1-cli/mkdocs.yml b/gen/compute1-cli/mkdocs.yml deleted file mode 100644 index cd00abf6dc..0000000000 --- a/gen/compute1-cli/mkdocs.yml +++ /dev/null @@ -1,238 +0,0 @@ -site_name: compute v0.3.6+20160908 -site_url: http://byron.github.io/google-apis-rs/google-compute1-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/compute1-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['addresses_aggregated-list.md', 'Addresses', 'Aggregated List'] -- ['addresses_delete.md', 'Addresses', 'Delete'] -- ['addresses_get.md', 'Addresses', 'Get'] -- ['addresses_insert.md', 'Addresses', 'Insert'] -- ['addresses_list.md', 'Addresses', 'List'] -- ['autoscalers_aggregated-list.md', 'Autoscalers', 'Aggregated List'] -- ['autoscalers_delete.md', 'Autoscalers', 'Delete'] -- ['autoscalers_get.md', 'Autoscalers', 'Get'] -- ['autoscalers_insert.md', 'Autoscalers', 'Insert'] -- ['autoscalers_list.md', 'Autoscalers', 'List'] -- ['autoscalers_patch.md', 'Autoscalers', 'Patch'] -- ['autoscalers_update.md', 'Autoscalers', 'Update'] -- ['backend-services_delete.md', 'Backend Services', 'Delete'] -- ['backend-services_get.md', 'Backend Services', 'Get'] -- ['backend-services_get-health.md', 'Backend Services', 'Get Health'] -- ['backend-services_insert.md', 'Backend Services', 'Insert'] -- ['backend-services_list.md', 'Backend Services', 'List'] -- ['backend-services_patch.md', 'Backend Services', 'Patch'] -- ['backend-services_update.md', 'Backend Services', 'Update'] -- ['disk-types_aggregated-list.md', 'Disk Types', 'Aggregated List'] -- ['disk-types_get.md', 'Disk Types', 'Get'] -- ['disk-types_list.md', 'Disk Types', 'List'] -- ['disks_aggregated-list.md', 'Disks', 'Aggregated List'] -- ['disks_create-snapshot.md', 'Disks', 'Create Snapshot'] -- ['disks_delete.md', 'Disks', 'Delete'] -- ['disks_get.md', 'Disks', 'Get'] -- ['disks_insert.md', 'Disks', 'Insert'] -- ['disks_list.md', 'Disks', 'List'] -- ['disks_resize.md', 'Disks', 'Resize'] -- ['firewalls_delete.md', 'Firewalls', 'Delete'] -- ['firewalls_get.md', 'Firewalls', 'Get'] -- ['firewalls_insert.md', 'Firewalls', 'Insert'] -- ['firewalls_list.md', 'Firewalls', 'List'] -- ['firewalls_patch.md', 'Firewalls', 'Patch'] -- ['firewalls_update.md', 'Firewalls', 'Update'] -- ['forwarding-rules_aggregated-list.md', 'Forwarding Rules', 'Aggregated List'] -- ['forwarding-rules_delete.md', 'Forwarding Rules', 'Delete'] -- ['forwarding-rules_get.md', 'Forwarding Rules', 'Get'] -- ['forwarding-rules_insert.md', 'Forwarding Rules', 'Insert'] -- ['forwarding-rules_list.md', 'Forwarding Rules', 'List'] -- ['forwarding-rules_set-target.md', 'Forwarding Rules', 'Set Target'] -- ['global-addresses_delete.md', 'Global Addresses', 'Delete'] -- ['global-addresses_get.md', 'Global Addresses', 'Get'] -- ['global-addresses_insert.md', 'Global Addresses', 'Insert'] -- ['global-addresses_list.md', 'Global Addresses', 'List'] -- ['global-forwarding-rules_delete.md', 'Global Forwarding Rules', 'Delete'] -- ['global-forwarding-rules_get.md', 'Global Forwarding Rules', 'Get'] -- ['global-forwarding-rules_insert.md', 'Global Forwarding Rules', 'Insert'] -- ['global-forwarding-rules_list.md', 'Global Forwarding Rules', 'List'] -- ['global-forwarding-rules_set-target.md', 'Global Forwarding Rules', 'Set Target'] -- ['global-operations_aggregated-list.md', 'Global Operations', 'Aggregated List'] -- ['global-operations_delete.md', 'Global Operations', 'Delete'] -- ['global-operations_get.md', 'Global Operations', 'Get'] -- ['global-operations_list.md', 'Global Operations', 'List'] -- ['health-checks_delete.md', 'Health Checks', 'Delete'] -- ['health-checks_get.md', 'Health Checks', 'Get'] -- ['health-checks_insert.md', 'Health Checks', 'Insert'] -- ['health-checks_list.md', 'Health Checks', 'List'] -- ['health-checks_patch.md', 'Health Checks', 'Patch'] -- ['health-checks_update.md', 'Health Checks', 'Update'] -- ['http-health-checks_delete.md', 'Http Health Checks', 'Delete'] -- ['http-health-checks_get.md', 'Http Health Checks', 'Get'] -- ['http-health-checks_insert.md', 'Http Health Checks', 'Insert'] -- ['http-health-checks_list.md', 'Http Health Checks', 'List'] -- ['http-health-checks_patch.md', 'Http Health Checks', 'Patch'] -- ['http-health-checks_update.md', 'Http Health Checks', 'Update'] -- ['https-health-checks_delete.md', 'Https Health Checks', 'Delete'] -- ['https-health-checks_get.md', 'Https Health Checks', 'Get'] -- ['https-health-checks_insert.md', 'Https Health Checks', 'Insert'] -- ['https-health-checks_list.md', 'Https Health Checks', 'List'] -- ['https-health-checks_patch.md', 'Https Health Checks', 'Patch'] -- ['https-health-checks_update.md', 'Https Health Checks', 'Update'] -- ['images_delete.md', 'Images', 'Delete'] -- ['images_deprecate.md', 'Images', 'Deprecate'] -- ['images_get.md', 'Images', 'Get'] -- ['images_get-from-family.md', 'Images', 'Get From Family'] -- ['images_insert.md', 'Images', 'Insert'] -- ['images_list.md', 'Images', 'List'] -- ['instance-group-managers_abandon-instances.md', 'Instance Group Managers', 'Abandon Instances'] -- ['instance-group-managers_aggregated-list.md', 'Instance Group Managers', 'Aggregated List'] -- ['instance-group-managers_delete.md', 'Instance Group Managers', 'Delete'] -- ['instance-group-managers_delete-instances.md', 'Instance Group Managers', 'Delete Instances'] -- ['instance-group-managers_get.md', 'Instance Group Managers', 'Get'] -- ['instance-group-managers_insert.md', 'Instance Group Managers', 'Insert'] -- ['instance-group-managers_list.md', 'Instance Group Managers', 'List'] -- ['instance-group-managers_list-managed-instances.md', 'Instance Group Managers', 'List Managed Instances'] -- ['instance-group-managers_recreate-instances.md', 'Instance Group Managers', 'Recreate Instances'] -- ['instance-group-managers_resize.md', 'Instance Group Managers', 'Resize'] -- ['instance-group-managers_set-instance-template.md', 'Instance Group Managers', 'Set Instance Template'] -- ['instance-group-managers_set-target-pools.md', 'Instance Group Managers', 'Set Target Pools'] -- ['instance-groups_add-instances.md', 'Instance Groups', 'Add Instances'] -- ['instance-groups_aggregated-list.md', 'Instance Groups', 'Aggregated List'] -- ['instance-groups_delete.md', 'Instance Groups', 'Delete'] -- ['instance-groups_get.md', 'Instance Groups', 'Get'] -- ['instance-groups_insert.md', 'Instance Groups', 'Insert'] -- ['instance-groups_list.md', 'Instance Groups', 'List'] -- ['instance-groups_list-instances.md', 'Instance Groups', 'List Instances'] -- ['instance-groups_remove-instances.md', 'Instance Groups', 'Remove Instances'] -- ['instance-groups_set-named-ports.md', 'Instance Groups', 'Set Named Ports'] -- ['instance-templates_delete.md', 'Instance Templates', 'Delete'] -- ['instance-templates_get.md', 'Instance Templates', 'Get'] -- ['instance-templates_insert.md', 'Instance Templates', 'Insert'] -- ['instance-templates_list.md', 'Instance Templates', 'List'] -- ['instances_add-access-config.md', 'Instances', 'Add Access Config'] -- ['instances_aggregated-list.md', 'Instances', 'Aggregated List'] -- ['instances_attach-disk.md', 'Instances', 'Attach Disk'] -- ['instances_delete.md', 'Instances', 'Delete'] -- ['instances_delete-access-config.md', 'Instances', 'Delete Access Config'] -- ['instances_detach-disk.md', 'Instances', 'Detach Disk'] -- ['instances_get.md', 'Instances', 'Get'] -- ['instances_get-serial-port-output.md', 'Instances', 'Get Serial Port Output'] -- ['instances_insert.md', 'Instances', 'Insert'] -- ['instances_list.md', 'Instances', 'List'] -- ['instances_reset.md', 'Instances', 'Reset'] -- ['instances_set-disk-auto-delete.md', 'Instances', 'Set Disk Auto Delete'] -- ['instances_set-machine-type.md', 'Instances', 'Set Machine Type'] -- ['instances_set-metadata.md', 'Instances', 'Set Metadata'] -- ['instances_set-scheduling.md', 'Instances', 'Set Scheduling'] -- ['instances_set-tags.md', 'Instances', 'Set Tags'] -- ['instances_start.md', 'Instances', 'Start'] -- ['instances_start-with-encryption-key.md', 'Instances', 'Start With Encryption Key'] -- ['instances_stop.md', 'Instances', 'Stop'] -- ['licenses_get.md', 'Licenses', 'Get'] -- ['machine-types_aggregated-list.md', 'Machine Types', 'Aggregated List'] -- ['machine-types_get.md', 'Machine Types', 'Get'] -- ['machine-types_list.md', 'Machine Types', 'List'] -- ['networks_delete.md', 'Networks', 'Delete'] -- ['networks_get.md', 'Networks', 'Get'] -- ['networks_insert.md', 'Networks', 'Insert'] -- ['networks_list.md', 'Networks', 'List'] -- ['projects_get.md', 'Projects', 'Get'] -- ['projects_move-disk.md', 'Projects', 'Move Disk'] -- ['projects_move-instance.md', 'Projects', 'Move Instance'] -- ['projects_set-common-instance-metadata.md', 'Projects', 'Set Common Instance Metadata'] -- ['projects_set-usage-export-bucket.md', 'Projects', 'Set Usage Export Bucket'] -- ['region-operations_delete.md', 'Region Operations', 'Delete'] -- ['region-operations_get.md', 'Region Operations', 'Get'] -- ['region-operations_list.md', 'Region Operations', 'List'] -- ['regions_get.md', 'Regions', 'Get'] -- ['regions_list.md', 'Regions', 'List'] -- ['routers_aggregated-list.md', 'Routers', 'Aggregated List'] -- ['routers_delete.md', 'Routers', 'Delete'] -- ['routers_get.md', 'Routers', 'Get'] -- ['routers_get-router-status.md', 'Routers', 'Get Router Status'] -- ['routers_insert.md', 'Routers', 'Insert'] -- ['routers_list.md', 'Routers', 'List'] -- ['routers_patch.md', 'Routers', 'Patch'] -- ['routers_preview.md', 'Routers', 'Preview'] -- ['routers_update.md', 'Routers', 'Update'] -- ['routes_delete.md', 'Routes', 'Delete'] -- ['routes_get.md', 'Routes', 'Get'] -- ['routes_insert.md', 'Routes', 'Insert'] -- ['routes_list.md', 'Routes', 'List'] -- ['snapshots_delete.md', 'Snapshots', 'Delete'] -- ['snapshots_get.md', 'Snapshots', 'Get'] -- ['snapshots_list.md', 'Snapshots', 'List'] -- ['ssl-certificates_delete.md', 'Ssl Certificates', 'Delete'] -- ['ssl-certificates_get.md', 'Ssl Certificates', 'Get'] -- ['ssl-certificates_insert.md', 'Ssl Certificates', 'Insert'] -- ['ssl-certificates_list.md', 'Ssl Certificates', 'List'] -- ['subnetworks_aggregated-list.md', 'Subnetworks', 'Aggregated List'] -- ['subnetworks_delete.md', 'Subnetworks', 'Delete'] -- ['subnetworks_get.md', 'Subnetworks', 'Get'] -- ['subnetworks_insert.md', 'Subnetworks', 'Insert'] -- ['subnetworks_list.md', 'Subnetworks', 'List'] -- ['target-http-proxies_delete.md', 'Target Http Proxies', 'Delete'] -- ['target-http-proxies_get.md', 'Target Http Proxies', 'Get'] -- ['target-http-proxies_insert.md', 'Target Http Proxies', 'Insert'] -- ['target-http-proxies_list.md', 'Target Http Proxies', 'List'] -- ['target-http-proxies_set-url-map.md', 'Target Http Proxies', 'Set Url Map'] -- ['target-https-proxies_delete.md', 'Target Https Proxies', 'Delete'] -- ['target-https-proxies_get.md', 'Target Https Proxies', 'Get'] -- ['target-https-proxies_insert.md', 'Target Https Proxies', 'Insert'] -- ['target-https-proxies_list.md', 'Target Https Proxies', 'List'] -- ['target-https-proxies_set-ssl-certificates.md', 'Target Https Proxies', 'Set Ssl Certificates'] -- ['target-https-proxies_set-url-map.md', 'Target Https Proxies', 'Set Url Map'] -- ['target-instances_aggregated-list.md', 'Target Instances', 'Aggregated List'] -- ['target-instances_delete.md', 'Target Instances', 'Delete'] -- ['target-instances_get.md', 'Target Instances', 'Get'] -- ['target-instances_insert.md', 'Target Instances', 'Insert'] -- ['target-instances_list.md', 'Target Instances', 'List'] -- ['target-pools_add-health-check.md', 'Target Pools', 'Add Health Check'] -- ['target-pools_add-instance.md', 'Target Pools', 'Add Instance'] -- ['target-pools_aggregated-list.md', 'Target Pools', 'Aggregated List'] -- ['target-pools_delete.md', 'Target Pools', 'Delete'] -- ['target-pools_get.md', 'Target Pools', 'Get'] -- ['target-pools_get-health.md', 'Target Pools', 'Get Health'] -- ['target-pools_insert.md', 'Target Pools', 'Insert'] -- ['target-pools_list.md', 'Target Pools', 'List'] -- ['target-pools_remove-health-check.md', 'Target Pools', 'Remove Health Check'] -- ['target-pools_remove-instance.md', 'Target Pools', 'Remove Instance'] -- ['target-pools_set-backup.md', 'Target Pools', 'Set Backup'] -- ['target-ssl-proxies_delete.md', 'Target Ssl Proxies', 'Delete'] -- ['target-ssl-proxies_get.md', 'Target Ssl Proxies', 'Get'] -- ['target-ssl-proxies_insert.md', 'Target Ssl Proxies', 'Insert'] -- ['target-ssl-proxies_list.md', 'Target Ssl Proxies', 'List'] -- ['target-ssl-proxies_set-backend-service.md', 'Target Ssl Proxies', 'Set Backend Service'] -- ['target-ssl-proxies_set-proxy-header.md', 'Target Ssl Proxies', 'Set Proxy Header'] -- ['target-ssl-proxies_set-ssl-certificates.md', 'Target Ssl Proxies', 'Set Ssl Certificates'] -- ['target-vpn-gateways_aggregated-list.md', 'Target Vpn Gateways', 'Aggregated List'] -- ['target-vpn-gateways_delete.md', 'Target Vpn Gateways', 'Delete'] -- ['target-vpn-gateways_get.md', 'Target Vpn Gateways', 'Get'] -- ['target-vpn-gateways_insert.md', 'Target Vpn Gateways', 'Insert'] -- ['target-vpn-gateways_list.md', 'Target Vpn Gateways', 'List'] -- ['url-maps_delete.md', 'Url Maps', 'Delete'] -- ['url-maps_get.md', 'Url Maps', 'Get'] -- ['url-maps_insert.md', 'Url Maps', 'Insert'] -- ['url-maps_invalidate-cache.md', 'Url Maps', 'Invalidate Cache'] -- ['url-maps_list.md', 'Url Maps', 'List'] -- ['url-maps_patch.md', 'Url Maps', 'Patch'] -- ['url-maps_update.md', 'Url Maps', 'Update'] -- ['url-maps_validate.md', 'Url Maps', 'Validate'] -- ['vpn-tunnels_aggregated-list.md', 'Vpn Tunnels', 'Aggregated List'] -- ['vpn-tunnels_delete.md', 'Vpn Tunnels', 'Delete'] -- ['vpn-tunnels_get.md', 'Vpn Tunnels', 'Get'] -- ['vpn-tunnels_insert.md', 'Vpn Tunnels', 'Insert'] -- ['vpn-tunnels_list.md', 'Vpn Tunnels', 'List'] -- ['zone-operations_delete.md', 'Zone Operations', 'Delete'] -- ['zone-operations_get.md', 'Zone Operations', 'Get'] -- ['zone-operations_list.md', 'Zone Operations', 'List'] -- ['zones_get.md', 'Zones', 'Get'] -- ['zones_list.md', 'Zones', 'List'] - -theme: readthedocs - -copyright: Copyright © 2015-2016, `Sebastian Thiel` - diff --git a/gen/compute1-cli/src/cmn.rs b/gen/compute1-cli/src/cmn.rs deleted file mode 100644 index 779c1dc086..0000000000 --- a/gen/compute1-cli/src/cmn.rs +++ /dev/null @@ -1,721 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use serde_json as json; -use serde_json::value::Value; -use mime::Mime; -use clap::{App, SubCommand}; -use strsim; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - - -pub enum ComplexType { - Pod, - Vec, - Map, -} - - // Null, - // Bool(bool), - // I64(i64), - // U64(u64), - // F64(f64), - // String(String), - -pub enum JsonType { - Boolean, - Int, - Uint, - Float, - String, -} - -pub struct JsonTypeInfo { - pub jtype: JsonType, - pub ctype: ComplexType, -} - -// Based on @erickt user comment. Thanks for the idea ! -// Remove all keys whose values are null from given value (changed in place) -pub fn remove_json_null_values(value: &mut Value) { - match *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); - } - } - _ => {} - } -} - -fn did_you_mean<'a>(v: &str, possible_values: &[&'a str]) -> Option<&'a str> { - - let mut candidate: Option<(f64, &str)> = None; - for pv in possible_values { - let confidence = strsim::jaro_winkler(v, pv); - if confidence > 0.8 && (candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence)) { - candidate = Some((confidence, pv)); - } - } - match candidate { - None => None, - Some((_, candidate)) => Some(candidate), - } -} - -pub enum CallType { - Upload(UploadProtocol), - Standard, -} - -arg_enum!{ - pub enum UploadProtocol { - Simple, - Resumable - } -} - -impl AsRef for UploadProtocol { - fn as_ref(&self) -> &str { - match *self { - UploadProtocol::Simple => "simple", - UploadProtocol::Resumable => "resumable" - } - } -} - -impl AsRef for CallType { - fn as_ref(&self) -> &str { - match *self { - CallType::Upload(ref proto) => proto.as_ref(), - CallType::Standard => "standard-request" - } - } -} - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.join(".") - } -} - -impl From<&'static str> for FieldCursor { - fn from(value: &'static str) -> FieldCursor { - let mut res = FieldCursor::default(); - res.set(value).unwrap(); - res - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn did_you_mean(value: &str, possible_values: &[&str]) -> Option { - if value.len() == 0 { - return None - } - - let mut last_c = FIELD_SEP; - - let mut field = String::new(); - let mut output = String::new(); - - let push_field = |fs: &mut String, f: &mut String| { - if f.len() > 0 { - fs.push_str( - match did_you_mean(&f, possible_values) { - Some(candidate) => candidate, - None => &f, - }); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - if c == FIELD_SEP { - if last_c != FIELD_SEP { - push_field(&mut output, &mut field); - } - output.push(c); - } else { - field.push(c); - } - - last_c = c; - } - - push_field(&mut output, &mut field); - - if &output == value { - None - } else { - Some(output) - } - } - - pub fn set_json_value(&self, mut object: &mut Value, - value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, - orig_cursor: &FieldCursor) { - assert!(self.0.len() > 0); - - for field in &self.0[..self.0.len()-1] { - let tmp = object; - object = - match *tmp { - Value::Object(ref mut mapping) => { - mapping.entry(field.to_owned()).or_insert( - Value::Object(Default::default()) - ) - }, - _ => panic!("We don't expect non-object Values here ...") - }; - } - - match *object { - Value::Object(ref mut mapping) => { - let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| - -> Value { - match jtype { - JsonType::Boolean => - Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => - Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => - Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => - Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => - Value::String(value.to_owned()), - } - }; - - match type_info.ctype { - ComplexType::Pod => { - if mapping.insert(field.to_owned(), to_jval(value, type_info.jtype, err)).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - }, - ComplexType::Vec => { - match *mapping.entry(field.to_owned()) - .or_insert(Value::Array(Default::default())) { - Value::Array(ref mut values) => values.push(to_jval(value, type_info.jtype, err)), - _ => unreachable!() - } - }, - ComplexType::Map => { - let (key, value) = parse_kv_arg(value, err, true); - let jval = to_jval(value.unwrap_or(""), type_info.jtype, err); - - match *mapping.entry(field.to_owned()) - .or_insert(Value::Object(Default::default())) { - Value::Object(ref mut value_map) => { - if value_map.insert(key.to_owned(), jval).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - } - _ => unreachable!() - } - } - } - }, - _ => unreachable!() - } - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); - match kv.find('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, Some("")) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut InvalidOptionsError) -> CallType { - CallType::Upload( - match UploadProtocol::from_str(name) { - Ok(up) => up, - Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); - UploadProtocol::Simple - } - }) -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::Io((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { - let f = arg.unwrap_or("-"); - match f { - "-" => Ok(Box::new(stdout())), - _ => match fs::OpenOptions::new().create(true).write(true).open(f) { - Ok(f) => Ok(Box::new(f)), - Err(io_err) => Err(io_err), - } - } -} - - -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, - arg_type: &'a str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError(arg_name.to_owned(), arg_type.to_owned(), arg.to_string(), format!("{}", perr)) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - type Error = json::Error; - - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Result<(), json::Error> { - match token { - None => { - match fs::remove_file(self.path(scope_hash)) { - Err(err) => - match err.kind() { - io::ErrorKind::NotFound => Ok(()), - _ => Err(json::Error::Io(err)) - }, - Ok(_) => Ok(()), - } - } - Some(token) => { - match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { - Ok(mut f) => { - match json::to_writer_pretty(&mut f, &token) { - Ok(_) => Ok(()), - Err(serde_err) => Err(serde_err), - } - }, - Err(io_err) => Err(json::Error::Io(io_err)) - } - } - } - } - - fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, json::Error> { - match fs::File::open(&self.path(scope_hash)) { - Ok(f) => { - match json::de::from_reader(f) { - Ok(token) => Ok(Some(token)), - Err(err) => Err(err), - } - }, - Err(io_err) => { - match io_err.kind() { - io::ErrorKind::NotFound => Ok(None), - _ => Err(json::Error::Io(io_err)) - } - } - } - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::Error)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - Io((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty."), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::Io((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}.", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - Io((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::Io((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}.", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type.", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String, Option, Option), - Duplicate(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor.", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character.", field), - FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = - match *suggestion { - Some(ref s) => { - let kv = - match *value { - Some(ref v) => format!("{}={}", s, v), - None => s.clone(), - }; - format!(" Did you mean '{}' ?", kv) - }, - None => String::new(), - }; - writeln!(f, "Field '{}' does not exist.{}", field, suffix) - }, - FieldError::Duplicate(ref cursor) - => writeln!(f, "Value at '{}' was already set", cursor), - FieldError::Empty - => writeln!(f, "Field names must not be empty."), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError(String, String, String, String), - UnknownParameter(String, Vec<&'static str>), - InvalidUploadProtocol(String, Vec), - InvalidKeyValueSyntax(String, bool), - Input(InputError), - Field(FieldError), - MissingCommandError, - MissingMethodError(String), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let suffix = - match did_you_mean(param_name, &possible_values) { - Some(v) => format!(" Did you mean '{}' ?", v), - None => String::new(), - }; - write!(f, "Parameter '{}' is unknown.{}\n", param_name, suffix) - }, - CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { - let hashmap_info = if is_hashmap { "hashmap " } else { "" }; - writeln!(f, "'{}' does not match {}pattern =.", kv, hashmap_info) - }, - CLIError::MissingCommandError => writeln!(f, "Please specify the main sub-command."), - CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the '{}' command.", cmd), - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, - json_console_secret: &str) - -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::Io( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret - = json::from_str(json_console_secret).unwrap(); - match json::to_writer_pretty(&mut f, &console_secret) { - Err(serde_err) => match serde_err { - json::Error::Io(err) => err, - _ => panic!("Unexpected serde error: {:#?}", serde_err) - }, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(f) => { - match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::Io(err)) => - return secret_io_error(err), - Err(json_err) => - return Err(CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::DecoderError( - (secret_str(), json_err) - )))), - Ok(console_secret) => - match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} diff --git a/gen/compute1-cli/src/main.rs b/gen/compute1-cli/src/main.rs deleted file mode 100644 index 10071e9a6d..0000000000 --- a/gen/compute1-cli/src/main.rs +++ /dev/null @@ -1,23732 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -#[macro_use] -extern crate clap; -extern crate yup_oauth2 as oauth2; -extern crate yup_hyper_mock as mock; -extern crate serde; -extern crate serde_json; -extern crate hyper; -extern crate mime; -extern crate strsim; -extern crate google_compute1 as api; - -use std::env; -use std::io::{self, Write}; -use clap::{App, SubCommand, Arg}; - -mod cmn; - -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol, - calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, FlowType}; -use serde_json as json; -use clap::ArgMatches; - -enum DoitError { - IoError(String, io::Error), - ApiError(api::Error), -} - -struct Engine<'n> { - opt: ArgMatches<'n>, - hub: api::Compute>, - gp: Vec<&'static str>, - gpm: Vec<(&'static str, &'static str)>, -} - - -impl<'n> Engine<'n> { - fn _addresses_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.addresses().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _addresses_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.addresses().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("address").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _addresses_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.addresses().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("address").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _addresses_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "address" => Some(("address", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "users" => Some(("users", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["address", "creation-timestamp", "description", "id", "kind", "name", "region", "self-link", "status", "users"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Address = json::value::from_value(object).unwrap(); - let mut call = self.hub.addresses().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _addresses_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.addresses().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _autoscalers_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.autoscalers().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _autoscalers_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.autoscalers().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("autoscaler").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _autoscalers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.autoscalers().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("autoscaler").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _autoscalers_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "autoscaling-policy.max-num-replicas" => Some(("autoscalingPolicy.maxNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "autoscaling-policy.cpu-utilization.utilization-target" => Some(("autoscalingPolicy.cpuUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), - "autoscaling-policy.min-num-replicas" => Some(("autoscalingPolicy.minNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "autoscaling-policy.cool-down-period-sec" => Some(("autoscalingPolicy.coolDownPeriodSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "autoscaling-policy.load-balancing-utilization.utilization-target" => Some(("autoscalingPolicy.loadBalancingUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), - "target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "cool-down-period-sec", "cpu-utilization", "creation-timestamp", "description", "id", "kind", "load-balancing-utilization", "max-num-replicas", "min-num-replicas", "name", "self-link", "target", "utilization-target", "zone"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Autoscaler = json::value::from_value(object).unwrap(); - let mut call = self.hub.autoscalers().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _autoscalers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.autoscalers().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _autoscalers_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "autoscaling-policy.max-num-replicas" => Some(("autoscalingPolicy.maxNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "autoscaling-policy.cpu-utilization.utilization-target" => Some(("autoscalingPolicy.cpuUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), - "autoscaling-policy.min-num-replicas" => Some(("autoscalingPolicy.minNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "autoscaling-policy.cool-down-period-sec" => Some(("autoscalingPolicy.coolDownPeriodSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "autoscaling-policy.load-balancing-utilization.utilization-target" => Some(("autoscalingPolicy.loadBalancingUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), - "target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "cool-down-period-sec", "cpu-utilization", "creation-timestamp", "description", "id", "kind", "load-balancing-utilization", "max-num-replicas", "min-num-replicas", "name", "self-link", "target", "utilization-target", "zone"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Autoscaler = json::value::from_value(object).unwrap(); - let mut call = self.hub.autoscalers().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("autoscaler").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _autoscalers_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "autoscaling-policy.max-num-replicas" => Some(("autoscalingPolicy.maxNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "autoscaling-policy.cpu-utilization.utilization-target" => Some(("autoscalingPolicy.cpuUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), - "autoscaling-policy.min-num-replicas" => Some(("autoscalingPolicy.minNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "autoscaling-policy.cool-down-period-sec" => Some(("autoscalingPolicy.coolDownPeriodSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "autoscaling-policy.load-balancing-utilization.utilization-target" => Some(("autoscalingPolicy.loadBalancingUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), - "target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "cool-down-period-sec", "cpu-utilization", "creation-timestamp", "description", "id", "kind", "load-balancing-utilization", "max-num-replicas", "min-num-replicas", "name", "self-link", "target", "utilization-target", "zone"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Autoscaler = json::value::from_value(object).unwrap(); - let mut call = self.hub.autoscalers().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "autoscaler" => { - call = call.autoscaler(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["autoscaler"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _backend_services_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.backend_services().delete(opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _backend_services_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.backend_services().get(opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _backend_services_get_health(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "group" => Some(("group", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["group"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::ResourceGroupReference = json::value::from_value(object).unwrap(); - let mut call = self.hub.backend_services().get_health(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _backend_services_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "connection-draining.draining-timeout-sec" => Some(("connectionDraining.drainingTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "protocol" => Some(("protocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "enable-cdn" => Some(("enableCDN", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "affinity-cookie-ttl-sec" => Some(("affinityCookieTtlSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "port-name" => Some(("portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["affinity-cookie-ttl-sec", "connection-draining", "creation-timestamp", "description", "draining-timeout-sec", "enable-cdn", "fingerprint", "health-checks", "id", "kind", "name", "port", "port-name", "protocol", "region", "self-link", "session-affinity", "timeout-sec"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::BackendService = json::value::from_value(object).unwrap(); - let mut call = self.hub.backend_services().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _backend_services_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.backend_services().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _backend_services_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "connection-draining.draining-timeout-sec" => Some(("connectionDraining.drainingTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "protocol" => Some(("protocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "enable-cdn" => Some(("enableCDN", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "affinity-cookie-ttl-sec" => Some(("affinityCookieTtlSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "port-name" => Some(("portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["affinity-cookie-ttl-sec", "connection-draining", "creation-timestamp", "description", "draining-timeout-sec", "enable-cdn", "fingerprint", "health-checks", "id", "kind", "name", "port", "port-name", "protocol", "region", "self-link", "session-affinity", "timeout-sec"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::BackendService = json::value::from_value(object).unwrap(); - let mut call = self.hub.backend_services().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _backend_services_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "connection-draining.draining-timeout-sec" => Some(("connectionDraining.drainingTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "protocol" => Some(("protocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "enable-cdn" => Some(("enableCDN", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "affinity-cookie-ttl-sec" => Some(("affinityCookieTtlSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "port-name" => Some(("portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["affinity-cookie-ttl-sec", "connection-draining", "creation-timestamp", "description", "draining-timeout-sec", "enable-cdn", "fingerprint", "health-checks", "id", "kind", "name", "port", "port-name", "protocol", "region", "self-link", "session-affinity", "timeout-sec"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::BackendService = json::value::from_value(object).unwrap(); - let mut call = self.hub.backend_services().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _disk_types_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.disk_types().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _disk_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.disk_types().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk-type").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _disk_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.disk_types().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _disks_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.disks().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _disks_create_snapshot(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-disk-encryption-key.raw-key" => Some(("sourceDiskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-disk-encryption-key.sha256" => Some(("sourceDiskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "storage-bytes" => Some(("storageBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-disk" => Some(("sourceDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "snapshot-encryption-key.raw-key" => Some(("snapshotEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "snapshot-encryption-key.sha256" => Some(("snapshotEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "storage-bytes-status" => Some(("storageBytesStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-disk-id" => Some(("sourceDiskId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "disk-size-gb" => Some(("diskSizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "disk-size-gb", "id", "kind", "licenses", "name", "raw-key", "self-link", "sha256", "snapshot-encryption-key", "source-disk", "source-disk-encryption-key", "source-disk-id", "status", "storage-bytes", "storage-bytes-status"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Snapshot = json::value::from_value(object).unwrap(); - let mut call = self.hub.disks().create_snapshot(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _disks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.disks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _disks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.disks().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _disks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "source-image-encryption-key.raw-key" => Some(("sourceImageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-image-encryption-key.sha256" => Some(("sourceImageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "users" => Some(("users", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "disk-encryption-key.raw-key" => Some(("diskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "disk-encryption-key.sha256" => Some(("diskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "last-attach-timestamp" => Some(("lastAttachTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-snapshot" => Some(("sourceSnapshot", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "last-detach-timestamp" => Some(("lastDetachTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-image-id" => Some(("sourceImageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-image" => Some(("sourceImage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-snapshot-id" => Some(("sourceSnapshotId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "size-gb" => Some(("sizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-snapshot-encryption-key.raw-key" => Some(("sourceSnapshotEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-snapshot-encryption-key.sha256" => Some(("sourceSnapshotEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "options" => Some(("options", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "disk-encryption-key", "id", "kind", "last-attach-timestamp", "last-detach-timestamp", "licenses", "name", "options", "raw-key", "self-link", "sha256", "size-gb", "source-image", "source-image-encryption-key", "source-image-id", "source-snapshot", "source-snapshot-encryption-key", "source-snapshot-id", "status", "type", "users", "zone"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Disk = json::value::from_value(object).unwrap(); - let mut call = self.hub.disks().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "source-image" => { - call = call.source_image(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["source-image"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _disks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.disks().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _disks_resize(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "size-gb" => Some(("sizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["size-gb"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::DisksResizeRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.disks().resize(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _firewalls_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.firewalls().delete(opt.value_of("project").unwrap_or(""), opt.value_of("firewall").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _firewalls_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.firewalls().get(opt.value_of("project").unwrap_or(""), opt.value_of("firewall").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _firewalls_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-tags" => Some(("sourceTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "source-ranges" => Some(("sourceRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "target-tags" => Some(("targetTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "kind", "name", "network", "self-link", "source-ranges", "source-tags", "target-tags"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Firewall = json::value::from_value(object).unwrap(); - let mut call = self.hub.firewalls().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _firewalls_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.firewalls().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _firewalls_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-tags" => Some(("sourceTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "source-ranges" => Some(("sourceRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "target-tags" => Some(("targetTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "kind", "name", "network", "self-link", "source-ranges", "source-tags", "target-tags"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Firewall = json::value::from_value(object).unwrap(); - let mut call = self.hub.firewalls().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("firewall").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _firewalls_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-tags" => Some(("sourceTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "source-ranges" => Some(("sourceRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "target-tags" => Some(("targetTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "kind", "name", "network", "self-link", "source-ranges", "source-tags", "target-tags"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Firewall = json::value::from_value(object).unwrap(); - let mut call = self.hub.firewalls().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("firewall").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _forwarding_rules_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.forwarding_rules().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _forwarding_rules_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.forwarding_rules().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _forwarding_rules_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.forwarding_rules().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _forwarding_rules_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ip-address" => Some(("IPAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "port-range" => Some(("portRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ip-protocol" => Some(("IPProtocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["ip-address", "ip-protocol", "creation-timestamp", "description", "id", "kind", "name", "port-range", "region", "self-link", "target"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::ForwardingRule = json::value::from_value(object).unwrap(); - let mut call = self.hub.forwarding_rules().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _forwarding_rules_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.forwarding_rules().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _forwarding_rules_set_target(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["target"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetReference = json::value::from_value(object).unwrap(); - let mut call = self.hub.forwarding_rules().set_target(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_addresses_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.global_addresses().delete(opt.value_of("project").unwrap_or(""), opt.value_of("address").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_addresses_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.global_addresses().get(opt.value_of("project").unwrap_or(""), opt.value_of("address").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_addresses_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "address" => Some(("address", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "users" => Some(("users", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["address", "creation-timestamp", "description", "id", "kind", "name", "region", "self-link", "status", "users"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Address = json::value::from_value(object).unwrap(); - let mut call = self.hub.global_addresses().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_addresses_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.global_addresses().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_forwarding_rules_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.global_forwarding_rules().delete(opt.value_of("project").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_forwarding_rules_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.global_forwarding_rules().get(opt.value_of("project").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_forwarding_rules_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ip-address" => Some(("IPAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "port-range" => Some(("portRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ip-protocol" => Some(("IPProtocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["ip-address", "ip-protocol", "creation-timestamp", "description", "id", "kind", "name", "port-range", "region", "self-link", "target"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::ForwardingRule = json::value::from_value(object).unwrap(); - let mut call = self.hub.global_forwarding_rules().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_forwarding_rules_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.global_forwarding_rules().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_forwarding_rules_set_target(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["target"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetReference = json::value::from_value(object).unwrap(); - let mut call = self.hub.global_forwarding_rules().set_target(request, opt.value_of("project").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_operations_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.global_operations().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_operations_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.global_operations().delete(opt.value_of("project").unwrap_or(""), opt.value_of("operation").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok(mut response) => { - Ok(()) - } - } - } - } - - fn _global_operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.global_operations().get(opt.value_of("project").unwrap_or(""), opt.value_of("operation").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _global_operations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.global_operations().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _health_checks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.health_checks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _health_checks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.health_checks().get(opt.value_of("project").unwrap_or(""), opt.value_of("health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _health_checks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "tcp-health-check.port-name" => Some(("tcpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tcp-health-check.request" => Some(("tcpHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tcp-health-check.proxy-header" => Some(("tcpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tcp-health-check.port" => Some(("tcpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "tcp-health-check.response" => Some(("tcpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.port-name" => Some(("httpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.host" => Some(("httpHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.proxy-header" => Some(("httpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.port" => Some(("httpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "http-health-check.request-path" => Some(("httpHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.port-name" => Some(("httpsHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.host" => Some(("httpsHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.proxy-header" => Some(("httpsHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.port" => Some(("httpsHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "https-health-check.request-path" => Some(("httpsHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "ssl-health-check.port-name" => Some(("sslHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-health-check.request" => Some(("sslHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-health-check.proxy-header" => Some(("sslHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-health-check.port" => Some(("sslHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "ssl-health-check.response" => Some(("sslHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.port-name" => Some(("http2HealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.host" => Some(("http2HealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.proxy-header" => Some(("http2HealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.port" => Some(("http2HealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "http2-health-check.request-path" => Some(("http2HealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "http2-health-check", "http-health-check", "https-health-check", "id", "kind", "name", "port", "port-name", "proxy-header", "request", "request-path", "response", "self-link", "ssl-health-check", "tcp-health-check", "timeout-sec", "type", "unhealthy-threshold"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::HealthCheck = json::value::from_value(object).unwrap(); - let mut call = self.hub.health_checks().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _health_checks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.health_checks().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _health_checks_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "tcp-health-check.port-name" => Some(("tcpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tcp-health-check.request" => Some(("tcpHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tcp-health-check.proxy-header" => Some(("tcpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tcp-health-check.port" => Some(("tcpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "tcp-health-check.response" => Some(("tcpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.port-name" => Some(("httpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.host" => Some(("httpHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.proxy-header" => Some(("httpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.port" => Some(("httpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "http-health-check.request-path" => Some(("httpHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.port-name" => Some(("httpsHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.host" => Some(("httpsHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.proxy-header" => Some(("httpsHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.port" => Some(("httpsHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "https-health-check.request-path" => Some(("httpsHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "ssl-health-check.port-name" => Some(("sslHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-health-check.request" => Some(("sslHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-health-check.proxy-header" => Some(("sslHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-health-check.port" => Some(("sslHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "ssl-health-check.response" => Some(("sslHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.port-name" => Some(("http2HealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.host" => Some(("http2HealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.proxy-header" => Some(("http2HealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.port" => Some(("http2HealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "http2-health-check.request-path" => Some(("http2HealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "http2-health-check", "http-health-check", "https-health-check", "id", "kind", "name", "port", "port-name", "proxy-header", "request", "request-path", "response", "self-link", "ssl-health-check", "tcp-health-check", "timeout-sec", "type", "unhealthy-threshold"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::HealthCheck = json::value::from_value(object).unwrap(); - let mut call = self.hub.health_checks().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _health_checks_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "tcp-health-check.port-name" => Some(("tcpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tcp-health-check.request" => Some(("tcpHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tcp-health-check.proxy-header" => Some(("tcpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tcp-health-check.port" => Some(("tcpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "tcp-health-check.response" => Some(("tcpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.port-name" => Some(("httpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.host" => Some(("httpHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.proxy-header" => Some(("httpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http-health-check.port" => Some(("httpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "http-health-check.request-path" => Some(("httpHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.port-name" => Some(("httpsHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.host" => Some(("httpsHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.proxy-header" => Some(("httpsHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "https-health-check.port" => Some(("httpsHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "https-health-check.request-path" => Some(("httpsHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "ssl-health-check.port-name" => Some(("sslHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-health-check.request" => Some(("sslHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-health-check.proxy-header" => Some(("sslHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-health-check.port" => Some(("sslHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "ssl-health-check.response" => Some(("sslHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.port-name" => Some(("http2HealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.host" => Some(("http2HealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.proxy-header" => Some(("http2HealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "http2-health-check.port" => Some(("http2HealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "http2-health-check.request-path" => Some(("http2HealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "http2-health-check", "http-health-check", "https-health-check", "id", "kind", "name", "port", "port-name", "proxy-header", "request", "request-path", "response", "self-link", "ssl-health-check", "tcp-health-check", "timeout-sec", "type", "unhealthy-threshold"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::HealthCheck = json::value::from_value(object).unwrap(); - let mut call = self.hub.health_checks().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _http_health_checks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.http_health_checks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("http-health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _http_health_checks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.http_health_checks().get(opt.value_of("project").unwrap_or(""), opt.value_of("http-health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _http_health_checks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::HttpHealthCheck = json::value::from_value(object).unwrap(); - let mut call = self.hub.http_health_checks().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _http_health_checks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.http_health_checks().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _http_health_checks_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::HttpHealthCheck = json::value::from_value(object).unwrap(); - let mut call = self.hub.http_health_checks().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("http-health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _http_health_checks_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::HttpHealthCheck = json::value::from_value(object).unwrap(); - let mut call = self.hub.http_health_checks().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("http-health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _https_health_checks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.https_health_checks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("https-health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _https_health_checks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.https_health_checks().get(opt.value_of("project").unwrap_or(""), opt.value_of("https-health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _https_health_checks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::HttpsHealthCheck = json::value::from_value(object).unwrap(); - let mut call = self.hub.https_health_checks().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _https_health_checks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.https_health_checks().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _https_health_checks_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::HttpsHealthCheck = json::value::from_value(object).unwrap(); - let mut call = self.hub.https_health_checks().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("https-health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _https_health_checks_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::HttpsHealthCheck = json::value::from_value(object).unwrap(); - let mut call = self.hub.https_health_checks().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("https-health-check").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _images_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.images().delete(opt.value_of("project").unwrap_or(""), opt.value_of("image").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _images_deprecate(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "deleted" => Some(("deleted", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "deprecated" => Some(("deprecated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "obsolete" => Some(("obsolete", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "replacement" => Some(("replacement", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["deleted", "deprecated", "obsolete", "replacement", "state"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::DeprecationStatus = json::value::from_value(object).unwrap(); - let mut call = self.hub.images().deprecate(request, opt.value_of("project").unwrap_or(""), opt.value_of("image").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _images_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.images().get(opt.value_of("project").unwrap_or(""), opt.value_of("image").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _images_get_from_family(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.images().get_from_family(opt.value_of("project").unwrap_or(""), opt.value_of("family").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _images_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-disk-encryption-key.raw-key" => Some(("sourceDiskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-disk-encryption-key.sha256" => Some(("sourceDiskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "family" => Some(("family", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "image-encryption-key.raw-key" => Some(("imageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "image-encryption-key.sha256" => Some(("imageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "raw-disk.container-type" => Some(("rawDisk.containerType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "raw-disk.source" => Some(("rawDisk.source", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "raw-disk.sha1-checksum" => Some(("rawDisk.sha1Checksum", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "archive-size-bytes" => Some(("archiveSizeBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-disk-id" => Some(("sourceDiskId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "disk-size-gb" => Some(("diskSizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-disk" => Some(("sourceDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "deprecated.deleted" => Some(("deprecated.deleted", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "deprecated.deprecated" => Some(("deprecated.deprecated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "deprecated.state" => Some(("deprecated.state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "deprecated.obsolete" => Some(("deprecated.obsolete", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "deprecated.replacement" => Some(("deprecated.replacement", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-type" => Some(("sourceType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["archive-size-bytes", "container-type", "creation-timestamp", "deleted", "deprecated", "description", "disk-size-gb", "family", "id", "image-encryption-key", "kind", "licenses", "name", "obsolete", "raw-disk", "raw-key", "replacement", "self-link", "sha1-checksum", "sha256", "source", "source-disk", "source-disk-encryption-key", "source-disk-id", "source-type", "state", "status"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Image = json::value::from_value(object).unwrap(); - let mut call = self.hub.images().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _images_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.images().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_abandon_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["instances"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroupManagersAbandonInstancesRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_group_managers().abandon_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_group_managers().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_group_managers().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_delete_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["instances"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroupManagersDeleteInstancesRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_group_managers().delete_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_group_managers().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "current-actions.none" => Some(("currentActions.none", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "current-actions.recreating" => Some(("currentActions.recreating", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "current-actions.creating" => Some(("currentActions.creating", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "current-actions.restarting" => Some(("currentActions.restarting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "current-actions.abandoning" => Some(("currentActions.abandoning", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "current-actions.deleting" => Some(("currentActions.deleting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "current-actions.creating-without-retries" => Some(("currentActions.creatingWithoutRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "current-actions.refreshing" => Some(("currentActions.refreshing", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "instance-group" => Some(("instanceGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "target-size" => Some(("targetSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "target-pools" => Some(("targetPools", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "base-instance-name" => Some(("baseInstanceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "instance-template" => Some(("instanceTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["abandoning", "base-instance-name", "creating", "creating-without-retries", "creation-timestamp", "current-actions", "deleting", "description", "fingerprint", "id", "instance-group", "instance-template", "kind", "name", "none", "recreating", "refreshing", "restarting", "self-link", "target-pools", "target-size", "zone"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroupManager = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_group_managers().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_group_managers().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_list_managed_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_group_managers().list_managed_instances(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_recreate_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["instances"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroupManagersRecreateInstancesRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_group_managers().recreate_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_resize(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let size: i32 = arg_from_str(&opt.value_of("size").unwrap_or(""), err, "", "integer"); - let mut call = self.hub.instance_group_managers().resize(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""), size); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_set_instance_template(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "instance-template" => Some(("instanceTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["instance-template"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroupManagersSetInstanceTemplateRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_group_managers().set_instance_template(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_group_managers_set_target_pools(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "target-pools" => Some(("targetPools", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint", "target-pools"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroupManagersSetTargetPoolsRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_group_managers().set_target_pools(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_groups_add_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec![]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroupsAddInstancesRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_groups().add_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_groups_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_groups().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_groups_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_groups().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_groups().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_groups_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "size" => Some(("size", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "kind", "name", "network", "self-link", "size", "subnetwork", "zone"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroup = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_groups().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_groups().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_groups_list_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "instance-state" => Some(("instanceState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["instance-state"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroupsListInstancesRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_groups().list_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_groups_remove_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec![]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroupsRemoveInstancesRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_groups().remove_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_groups_set_named_ports(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceGroupsSetNamedPortsRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_groups().set_named_ports(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_templates_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_templates().delete(opt.value_of("project").unwrap_or(""), opt.value_of("instance-template").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_templates_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_templates().get(opt.value_of("project").unwrap_or(""), opt.value_of("instance-template").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_templates_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "properties.machine-type" => Some(("properties.machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "properties.description" => Some(("properties.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "properties.tags.items" => Some(("properties.tags.items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "properties.tags.fingerprint" => Some(("properties.tags.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "properties.scheduling.automatic-restart" => Some(("properties.scheduling.automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "properties.scheduling.preemptible" => Some(("properties.scheduling.preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "properties.scheduling.on-host-maintenance" => Some(("properties.scheduling.onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "properties.can-ip-forward" => Some(("properties.canIpForward", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "properties.metadata.kind" => Some(("properties.metadata.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "properties.metadata.fingerprint" => Some(("properties.metadata.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["automatic-restart", "can-ip-forward", "creation-timestamp", "description", "fingerprint", "id", "items", "kind", "machine-type", "metadata", "name", "on-host-maintenance", "preemptible", "properties", "scheduling", "self-link", "tags"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceTemplate = json::value::from_value(object).unwrap(); - let mut call = self.hub.instance_templates().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instance_templates_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instance_templates().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_add_access_config(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "nat-ip" => Some(("natIP", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "name", "nat-ip", "type"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::AccessConfig = json::value::from_value(object).unwrap(); - let mut call = self.hub.instances().add_access_config(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), opt.value_of("network-interface").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instances().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_attach_disk(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "disk-encryption-key.raw-key" => Some(("diskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "disk-encryption-key.sha256" => Some(("diskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "device-name" => Some(("deviceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "initialize-params.disk-size-gb" => Some(("initializeParams.diskSizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "initialize-params.source-image-encryption-key.raw-key" => Some(("initializeParams.sourceImageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "initialize-params.source-image-encryption-key.sha256" => Some(("initializeParams.sourceImageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "initialize-params.source-image" => Some(("initializeParams.sourceImage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "initialize-params.disk-name" => Some(("initializeParams.diskName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "initialize-params.disk-type" => Some(("initializeParams.diskType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "auto-delete" => Some(("autoDelete", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "index" => Some(("index", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "boot" => Some(("boot", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "mode" => Some(("mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "interface" => Some(("interface", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source" => Some(("source", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["auto-delete", "boot", "device-name", "disk-encryption-key", "disk-name", "disk-size-gb", "disk-type", "index", "initialize-params", "interface", "kind", "licenses", "mode", "raw-key", "sha256", "source", "source-image", "source-image-encryption-key", "type"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::AttachedDisk = json::value::from_value(object).unwrap(); - let mut call = self.hub.instances().attach_disk(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instances().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_delete_access_config(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instances().delete_access_config(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), opt.value_of("access-config").unwrap_or(""), opt.value_of("network-interface").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_detach_disk(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instances().detach_disk(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), opt.value_of("device-name").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instances().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_get_serial_port_output(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instances().get_serial_port_output(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "port" => { - call = call.port(arg_from_str(value.unwrap_or("-0"), err, "port", "integer")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["port"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "cpu-platform" => Some(("cpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "can-ip-forward" => Some(("canIpForward", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tags.items" => Some(("tags.items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "tags.fingerprint" => Some(("tags.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "status-message" => Some(("statusMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "scheduling.automatic-restart" => Some(("scheduling.automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "scheduling.preemptible" => Some(("scheduling.preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "scheduling.on-host-maintenance" => Some(("scheduling.onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "machine-type" => Some(("machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "metadata.kind" => Some(("metadata.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "metadata.fingerprint" => Some(("metadata.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["automatic-restart", "can-ip-forward", "cpu-platform", "creation-timestamp", "description", "fingerprint", "id", "items", "kind", "machine-type", "metadata", "name", "on-host-maintenance", "preemptible", "scheduling", "self-link", "status", "status-message", "tags", "zone"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Instance = json::value::from_value(object).unwrap(); - let mut call = self.hub.instances().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instances().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_reset(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instances().reset(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_set_disk_auto_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let auto_delete: bool = arg_from_str(&opt.value_of("auto-delete").unwrap_or(""), err, "", "boolean"); - let mut call = self.hub.instances().set_disk_auto_delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), auto_delete, opt.value_of("device-name").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_set_machine_type(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "machine-type" => Some(("machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["machine-type"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstancesSetMachineTypeRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instances().set_machine_type(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_set_metadata(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint", "kind"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Metadata = json::value::from_value(object).unwrap(); - let mut call = self.hub.instances().set_metadata(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_set_scheduling(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "automatic-restart" => Some(("automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "preemptible" => Some(("preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "on-host-maintenance" => Some(("onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["automatic-restart", "on-host-maintenance", "preemptible"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Scheduling = json::value::from_value(object).unwrap(); - let mut call = self.hub.instances().set_scheduling(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_set_tags(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "items" => Some(("items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint", "items"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Tags = json::value::from_value(object).unwrap(); - let mut call = self.hub.instances().set_tags(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_start(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instances().start(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_start_with_encryption_key(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec![]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstancesStartWithEncryptionKeyRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.instances().start_with_encryption_key(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _instances_stop(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.instances().stop(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _licenses_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.licenses().get(opt.value_of("project").unwrap_or(""), opt.value_of("license").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _machine_types_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.machine_types().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _machine_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.machine_types().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("machine-type").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _machine_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.machine_types().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _networks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.networks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _networks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.networks().get(opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _networks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "subnetworks" => Some(("subnetworks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "auto-create-subnetworks" => Some(("autoCreateSubnetworks", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "i-pv4-range" => Some(("IPv4Range", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "gateway-i-pv4" => Some(("gatewayIPv4", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["i-pv4-range", "auto-create-subnetworks", "creation-timestamp", "description", "gateway-i-pv4", "id", "kind", "name", "self-link", "subnetworks"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Network = json::value::from_value(object).unwrap(); - let mut call = self.hub.networks().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _networks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.networks().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.projects().get(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_move_disk(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "target-disk" => Some(("targetDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "destination-zone" => Some(("destinationZone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["destination-zone", "target-disk"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::DiskMoveRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.projects().move_disk(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_move_instance(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "target-instance" => Some(("targetInstance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "destination-zone" => Some(("destinationZone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["destination-zone", "target-instance"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceMoveRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.projects().move_instance(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_set_common_instance_metadata(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint", "kind"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Metadata = json::value::from_value(object).unwrap(); - let mut call = self.hub.projects().set_common_instance_metadata(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_set_usage_export_bucket(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "bucket-name" => Some(("bucketName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "report-name-prefix" => Some(("reportNamePrefix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket-name", "report-name-prefix"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::UsageExportLocation = json::value::from_value(object).unwrap(); - let mut call = self.hub.projects().set_usage_export_bucket(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _region_operations_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.region_operations().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("operation").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok(mut response) => { - Ok(()) - } - } - } - } - - fn _region_operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.region_operations().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("operation").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _region_operations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.region_operations().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _regions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.regions().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _regions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.regions().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routers_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.routers().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routers_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.routers().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.routers().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routers_get_router_status(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.routers().get_router_status(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routers_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "bgp.asn" => Some(("bgp.asn", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["asn", "bgp", "creation-timestamp", "description", "id", "kind", "name", "network", "region", "self-link"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Router = json::value::from_value(object).unwrap(); - let mut call = self.hub.routers().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.routers().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routers_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "bgp.asn" => Some(("bgp.asn", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["asn", "bgp", "creation-timestamp", "description", "id", "kind", "name", "network", "region", "self-link"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Router = json::value::from_value(object).unwrap(); - let mut call = self.hub.routers().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routers_preview(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "bgp.asn" => Some(("bgp.asn", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["asn", "bgp", "creation-timestamp", "description", "id", "kind", "name", "network", "region", "self-link"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Router = json::value::from_value(object).unwrap(); - let mut call = self.hub.routers().preview(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routers_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "bgp.asn" => Some(("bgp.asn", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["asn", "bgp", "creation-timestamp", "description", "id", "kind", "name", "network", "region", "self-link"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Router = json::value::from_value(object).unwrap(); - let mut call = self.hub.routers().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routes_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.routes().delete(opt.value_of("project").unwrap_or(""), opt.value_of("route").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routes_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.routes().get(opt.value_of("project").unwrap_or(""), opt.value_of("route").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routes_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "next-hop-gateway" => Some(("nextHopGateway", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tags" => Some(("tags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "next-hop-instance" => Some(("nextHopInstance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "next-hop-network" => Some(("nextHopNetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "next-hop-vpn-tunnel" => Some(("nextHopVpnTunnel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "dest-range" => Some(("destRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "next-hop-ip" => Some(("nextHopIp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "dest-range", "id", "kind", "name", "network", "next-hop-gateway", "next-hop-instance", "next-hop-ip", "next-hop-network", "next-hop-vpn-tunnel", "priority", "self-link", "tags"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Route = json::value::from_value(object).unwrap(); - let mut call = self.hub.routes().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _routes_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.routes().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _snapshots_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.snapshots().delete(opt.value_of("project").unwrap_or(""), opt.value_of("snapshot").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _snapshots_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.snapshots().get(opt.value_of("project").unwrap_or(""), opt.value_of("snapshot").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _snapshots_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.snapshots().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _ssl_certificates_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.ssl_certificates().delete(opt.value_of("project").unwrap_or(""), opt.value_of("ssl-certificate").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _ssl_certificates_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.ssl_certificates().get(opt.value_of("project").unwrap_or(""), opt.value_of("ssl-certificate").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _ssl_certificates_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "certificate" => Some(("certificate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "private-key" => Some(("privateKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["certificate", "creation-timestamp", "description", "id", "kind", "name", "private-key", "self-link"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::SslCertificate = json::value::from_value(object).unwrap(); - let mut call = self.hub.ssl_certificates().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _ssl_certificates_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.ssl_certificates().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _subnetworks_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.subnetworks().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _subnetworks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.subnetworks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("subnetwork").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _subnetworks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.subnetworks().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("subnetwork").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _subnetworks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ip-cidr-range" => Some(("ipCidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "gateway-address" => Some(("gatewayAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "gateway-address", "id", "ip-cidr-range", "kind", "name", "network", "region", "self-link"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Subnetwork = json::value::from_value(object).unwrap(); - let mut call = self.hub.subnetworks().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _subnetworks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.subnetworks().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_http_proxies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_http_proxies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("target-http-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_http_proxies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_http_proxies().get(opt.value_of("project").unwrap_or(""), opt.value_of("target-http-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_http_proxies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "kind", "name", "self-link", "url-map"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetHttpProxy = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_http_proxies().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_http_proxies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_http_proxies().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_http_proxies_set_url_map(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["url-map"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::UrlMapReference = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_http_proxies().set_url_map(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-http-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_https_proxies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_https_proxies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_https_proxies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_https_proxies().get(opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_https_proxies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "kind", "name", "self-link", "ssl-certificates", "url-map"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetHttpsProxy = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_https_proxies().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_https_proxies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_https_proxies().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_https_proxies_set_ssl_certificates(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["ssl-certificates"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetHttpsProxiesSetSslCertificatesRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_https_proxies().set_ssl_certificates(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_https_proxies_set_url_map(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["url-map"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::UrlMapReference = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_https_proxies().set_url_map(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_instances_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_instances().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_instances_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_instances().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("target-instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_instances_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_instances().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("target-instance").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_instances_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "nat-policy" => Some(("natPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "instance" => Some(("instance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "instance", "kind", "name", "nat-policy", "self-link", "zone"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetInstance = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_instances().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_instances_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_instances().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_add_health_check(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec![]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetPoolsAddHealthCheckRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_pools().add_health_check(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_add_instance(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec![]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetPoolsAddInstanceRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_pools().add_instance(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_pools().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_pools().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_pools().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_get_health(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "instance" => Some(("instance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["instance"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::InstanceReference = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_pools().get_health(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "failover-ratio" => Some(("failoverRatio", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "backup-pool" => Some(("backupPool", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["backup-pool", "creation-timestamp", "description", "failover-ratio", "health-checks", "id", "instances", "kind", "name", "region", "self-link", "session-affinity"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetPool = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_pools().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_pools().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_remove_health_check(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec![]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetPoolsRemoveHealthCheckRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_pools().remove_health_check(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_remove_instance(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec![]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetPoolsRemoveInstanceRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_pools().remove_instance(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_pools_set_backup(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["target"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetReference = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_pools().set_backup(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "failover-ratio" => { - call = call.failover_ratio(arg_from_str(value.unwrap_or("0.0"), err, "failover-ratio", "number")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["failover-ratio"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_ssl_proxies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_ssl_proxies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_ssl_proxies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_ssl_proxies().get(opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_ssl_proxies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "service" => Some(("service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "proxy-header" => Some(("proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "kind", "name", "proxy-header", "self-link", "service", "ssl-certificates"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetSslProxy = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_ssl_proxies().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_ssl_proxies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_ssl_proxies().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_ssl_proxies_set_backend_service(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "service" => Some(("service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["service"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetSslProxiesSetBackendServiceRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_ssl_proxies().set_backend_service(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_ssl_proxies_set_proxy_header(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "proxy-header" => Some(("proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["proxy-header"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetSslProxiesSetProxyHeaderRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_ssl_proxies().set_proxy_header(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_ssl_proxies_set_ssl_certificates(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["ssl-certificates"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetSslProxiesSetSslCertificatesRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_ssl_proxies().set_ssl_certificates(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_vpn_gateways_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_vpn_gateways().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_vpn_gateways_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_vpn_gateways().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-vpn-gateway").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_vpn_gateways_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_vpn_gateways().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-vpn-gateway").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_vpn_gateways_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "forwarding-rules" => Some(("forwardingRules", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "tunnels" => Some(("tunnels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "forwarding-rules", "id", "kind", "name", "network", "region", "self-link", "status", "tunnels"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::TargetVpnGateway = json::value::from_value(object).unwrap(); - let mut call = self.hub.target_vpn_gateways().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _target_vpn_gateways_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.target_vpn_gateways().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _url_maps_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.url_maps().delete(opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _url_maps_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.url_maps().get(opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _url_maps_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "default-service" => Some(("defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "default-service", "description", "fingerprint", "id", "kind", "name", "self-link"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::UrlMap = json::value::from_value(object).unwrap(); - let mut call = self.hub.url_maps().insert(request, opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _url_maps_invalidate_cache(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "path" => Some(("path", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["path"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::CacheInvalidationRule = json::value::from_value(object).unwrap(); - let mut call = self.hub.url_maps().invalidate_cache(request, opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _url_maps_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.url_maps().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _url_maps_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "default-service" => Some(("defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "default-service", "description", "fingerprint", "id", "kind", "name", "self-link"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::UrlMap = json::value::from_value(object).unwrap(); - let mut call = self.hub.url_maps().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _url_maps_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "default-service" => Some(("defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "default-service", "description", "fingerprint", "id", "kind", "name", "self-link"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::UrlMap = json::value::from_value(object).unwrap(); - let mut call = self.hub.url_maps().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _url_maps_validate(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "resource.kind" => Some(("resource.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "resource.description" => Some(("resource.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "resource.default-service" => Some(("resource.defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "resource.fingerprint" => Some(("resource.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "resource.creation-timestamp" => Some(("resource.creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "resource.id" => Some(("resource.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "resource.self-link" => Some(("resource.selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "resource.name" => Some(("resource.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "default-service", "description", "fingerprint", "id", "kind", "name", "resource", "self-link"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::UrlMapsValidateRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.url_maps().validate(request, opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _vpn_tunnels_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.vpn_tunnels().aggregated_list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _vpn_tunnels_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.vpn_tunnels().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("vpn-tunnel").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _vpn_tunnels_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.vpn_tunnels().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("vpn-tunnel").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _vpn_tunnels_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "detailed-status" => Some(("detailedStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ike-version" => Some(("ikeVersion", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "remote-traffic-selector" => Some(("remoteTrafficSelector", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "peer-ip" => Some(("peerIp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "local-traffic-selector" => Some(("localTrafficSelector", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "target-vpn-gateway" => Some(("targetVpnGateway", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "shared-secret-hash" => Some(("sharedSecretHash", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "router" => Some(("router", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "shared-secret" => Some(("sharedSecret", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "detailed-status", "id", "ike-version", "kind", "local-traffic-selector", "name", "peer-ip", "region", "remote-traffic-selector", "router", "self-link", "shared-secret", "shared-secret-hash", "status", "target-vpn-gateway"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::VpnTunnel = json::value::from_value(object).unwrap(); - let mut call = self.hub.vpn_tunnels().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _vpn_tunnels_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.vpn_tunnels().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _zone_operations_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.zone_operations().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("operation").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok(mut response) => { - Ok(()) - } - } - } - } - - fn _zone_operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.zone_operations().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("operation").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _zone_operations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.zone_operations().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _zones_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.zones().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _zones_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.zones().list(opt.value_of("project").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _doit(&self, dry_run: bool) -> Result, Option> { - let mut err = InvalidOptionsError::new(); - let mut call_result: Result<(), DoitError> = Ok(()); - let mut err_opt: Option = None; - match self.opt.subcommand() { - ("addresses", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._addresses_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._addresses_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._addresses_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._addresses_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._addresses_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("addresses".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("autoscalers", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._autoscalers_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._autoscalers_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._autoscalers_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._autoscalers_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._autoscalers_list(opt, dry_run, &mut err); - }, - ("patch", Some(opt)) => { - call_result = self._autoscalers_patch(opt, dry_run, &mut err); - }, - ("update", Some(opt)) => { - call_result = self._autoscalers_update(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("autoscalers".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("backend-services", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._backend_services_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._backend_services_get(opt, dry_run, &mut err); - }, - ("get-health", Some(opt)) => { - call_result = self._backend_services_get_health(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._backend_services_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._backend_services_list(opt, dry_run, &mut err); - }, - ("patch", Some(opt)) => { - call_result = self._backend_services_patch(opt, dry_run, &mut err); - }, - ("update", Some(opt)) => { - call_result = self._backend_services_update(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("backend-services".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("disk-types", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._disk_types_aggregated_list(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._disk_types_get(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._disk_types_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("disk-types".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("disks", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._disks_aggregated_list(opt, dry_run, &mut err); - }, - ("create-snapshot", Some(opt)) => { - call_result = self._disks_create_snapshot(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._disks_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._disks_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._disks_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._disks_list(opt, dry_run, &mut err); - }, - ("resize", Some(opt)) => { - call_result = self._disks_resize(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("disks".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("firewalls", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._firewalls_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._firewalls_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._firewalls_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._firewalls_list(opt, dry_run, &mut err); - }, - ("patch", Some(opt)) => { - call_result = self._firewalls_patch(opt, dry_run, &mut err); - }, - ("update", Some(opt)) => { - call_result = self._firewalls_update(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("firewalls".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("forwarding-rules", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._forwarding_rules_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._forwarding_rules_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._forwarding_rules_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._forwarding_rules_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._forwarding_rules_list(opt, dry_run, &mut err); - }, - ("set-target", Some(opt)) => { - call_result = self._forwarding_rules_set_target(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("forwarding-rules".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("global-addresses", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._global_addresses_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._global_addresses_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._global_addresses_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._global_addresses_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("global-addresses".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("global-forwarding-rules", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._global_forwarding_rules_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._global_forwarding_rules_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._global_forwarding_rules_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._global_forwarding_rules_list(opt, dry_run, &mut err); - }, - ("set-target", Some(opt)) => { - call_result = self._global_forwarding_rules_set_target(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("global-forwarding-rules".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("global-operations", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._global_operations_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._global_operations_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._global_operations_get(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._global_operations_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("global-operations".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("health-checks", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._health_checks_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._health_checks_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._health_checks_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._health_checks_list(opt, dry_run, &mut err); - }, - ("patch", Some(opt)) => { - call_result = self._health_checks_patch(opt, dry_run, &mut err); - }, - ("update", Some(opt)) => { - call_result = self._health_checks_update(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("health-checks".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("http-health-checks", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._http_health_checks_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._http_health_checks_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._http_health_checks_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._http_health_checks_list(opt, dry_run, &mut err); - }, - ("patch", Some(opt)) => { - call_result = self._http_health_checks_patch(opt, dry_run, &mut err); - }, - ("update", Some(opt)) => { - call_result = self._http_health_checks_update(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("http-health-checks".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("https-health-checks", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._https_health_checks_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._https_health_checks_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._https_health_checks_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._https_health_checks_list(opt, dry_run, &mut err); - }, - ("patch", Some(opt)) => { - call_result = self._https_health_checks_patch(opt, dry_run, &mut err); - }, - ("update", Some(opt)) => { - call_result = self._https_health_checks_update(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("https-health-checks".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("images", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._images_delete(opt, dry_run, &mut err); - }, - ("deprecate", Some(opt)) => { - call_result = self._images_deprecate(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._images_get(opt, dry_run, &mut err); - }, - ("get-from-family", Some(opt)) => { - call_result = self._images_get_from_family(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._images_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._images_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("images".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("instance-group-managers", Some(opt)) => { - match opt.subcommand() { - ("abandon-instances", Some(opt)) => { - call_result = self._instance_group_managers_abandon_instances(opt, dry_run, &mut err); - }, - ("aggregated-list", Some(opt)) => { - call_result = self._instance_group_managers_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._instance_group_managers_delete(opt, dry_run, &mut err); - }, - ("delete-instances", Some(opt)) => { - call_result = self._instance_group_managers_delete_instances(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._instance_group_managers_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._instance_group_managers_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._instance_group_managers_list(opt, dry_run, &mut err); - }, - ("list-managed-instances", Some(opt)) => { - call_result = self._instance_group_managers_list_managed_instances(opt, dry_run, &mut err); - }, - ("recreate-instances", Some(opt)) => { - call_result = self._instance_group_managers_recreate_instances(opt, dry_run, &mut err); - }, - ("resize", Some(opt)) => { - call_result = self._instance_group_managers_resize(opt, dry_run, &mut err); - }, - ("set-instance-template", Some(opt)) => { - call_result = self._instance_group_managers_set_instance_template(opt, dry_run, &mut err); - }, - ("set-target-pools", Some(opt)) => { - call_result = self._instance_group_managers_set_target_pools(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("instance-group-managers".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("instance-groups", Some(opt)) => { - match opt.subcommand() { - ("add-instances", Some(opt)) => { - call_result = self._instance_groups_add_instances(opt, dry_run, &mut err); - }, - ("aggregated-list", Some(opt)) => { - call_result = self._instance_groups_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._instance_groups_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._instance_groups_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._instance_groups_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._instance_groups_list(opt, dry_run, &mut err); - }, - ("list-instances", Some(opt)) => { - call_result = self._instance_groups_list_instances(opt, dry_run, &mut err); - }, - ("remove-instances", Some(opt)) => { - call_result = self._instance_groups_remove_instances(opt, dry_run, &mut err); - }, - ("set-named-ports", Some(opt)) => { - call_result = self._instance_groups_set_named_ports(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("instance-groups".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("instance-templates", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._instance_templates_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._instance_templates_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._instance_templates_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._instance_templates_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("instance-templates".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("instances", Some(opt)) => { - match opt.subcommand() { - ("add-access-config", Some(opt)) => { - call_result = self._instances_add_access_config(opt, dry_run, &mut err); - }, - ("aggregated-list", Some(opt)) => { - call_result = self._instances_aggregated_list(opt, dry_run, &mut err); - }, - ("attach-disk", Some(opt)) => { - call_result = self._instances_attach_disk(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._instances_delete(opt, dry_run, &mut err); - }, - ("delete-access-config", Some(opt)) => { - call_result = self._instances_delete_access_config(opt, dry_run, &mut err); - }, - ("detach-disk", Some(opt)) => { - call_result = self._instances_detach_disk(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._instances_get(opt, dry_run, &mut err); - }, - ("get-serial-port-output", Some(opt)) => { - call_result = self._instances_get_serial_port_output(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._instances_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._instances_list(opt, dry_run, &mut err); - }, - ("reset", Some(opt)) => { - call_result = self._instances_reset(opt, dry_run, &mut err); - }, - ("set-disk-auto-delete", Some(opt)) => { - call_result = self._instances_set_disk_auto_delete(opt, dry_run, &mut err); - }, - ("set-machine-type", Some(opt)) => { - call_result = self._instances_set_machine_type(opt, dry_run, &mut err); - }, - ("set-metadata", Some(opt)) => { - call_result = self._instances_set_metadata(opt, dry_run, &mut err); - }, - ("set-scheduling", Some(opt)) => { - call_result = self._instances_set_scheduling(opt, dry_run, &mut err); - }, - ("set-tags", Some(opt)) => { - call_result = self._instances_set_tags(opt, dry_run, &mut err); - }, - ("start", Some(opt)) => { - call_result = self._instances_start(opt, dry_run, &mut err); - }, - ("start-with-encryption-key", Some(opt)) => { - call_result = self._instances_start_with_encryption_key(opt, dry_run, &mut err); - }, - ("stop", Some(opt)) => { - call_result = self._instances_stop(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("instances".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("licenses", Some(opt)) => { - match opt.subcommand() { - ("get", Some(opt)) => { - call_result = self._licenses_get(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("licenses".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("machine-types", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._machine_types_aggregated_list(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._machine_types_get(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._machine_types_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("machine-types".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("networks", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._networks_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._networks_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._networks_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._networks_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("networks".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("projects", Some(opt)) => { - match opt.subcommand() { - ("get", Some(opt)) => { - call_result = self._projects_get(opt, dry_run, &mut err); - }, - ("move-disk", Some(opt)) => { - call_result = self._projects_move_disk(opt, dry_run, &mut err); - }, - ("move-instance", Some(opt)) => { - call_result = self._projects_move_instance(opt, dry_run, &mut err); - }, - ("set-common-instance-metadata", Some(opt)) => { - call_result = self._projects_set_common_instance_metadata(opt, dry_run, &mut err); - }, - ("set-usage-export-bucket", Some(opt)) => { - call_result = self._projects_set_usage_export_bucket(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("projects".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("region-operations", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._region_operations_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._region_operations_get(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._region_operations_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("region-operations".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("regions", Some(opt)) => { - match opt.subcommand() { - ("get", Some(opt)) => { - call_result = self._regions_get(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._regions_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("regions".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("routers", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._routers_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._routers_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._routers_get(opt, dry_run, &mut err); - }, - ("get-router-status", Some(opt)) => { - call_result = self._routers_get_router_status(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._routers_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._routers_list(opt, dry_run, &mut err); - }, - ("patch", Some(opt)) => { - call_result = self._routers_patch(opt, dry_run, &mut err); - }, - ("preview", Some(opt)) => { - call_result = self._routers_preview(opt, dry_run, &mut err); - }, - ("update", Some(opt)) => { - call_result = self._routers_update(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("routers".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("routes", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._routes_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._routes_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._routes_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._routes_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("routes".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("snapshots", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._snapshots_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._snapshots_get(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._snapshots_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("snapshots".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("ssl-certificates", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._ssl_certificates_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._ssl_certificates_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._ssl_certificates_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._ssl_certificates_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("ssl-certificates".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("subnetworks", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._subnetworks_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._subnetworks_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._subnetworks_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._subnetworks_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._subnetworks_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("subnetworks".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("target-http-proxies", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._target_http_proxies_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._target_http_proxies_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._target_http_proxies_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._target_http_proxies_list(opt, dry_run, &mut err); - }, - ("set-url-map", Some(opt)) => { - call_result = self._target_http_proxies_set_url_map(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("target-http-proxies".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("target-https-proxies", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._target_https_proxies_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._target_https_proxies_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._target_https_proxies_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._target_https_proxies_list(opt, dry_run, &mut err); - }, - ("set-ssl-certificates", Some(opt)) => { - call_result = self._target_https_proxies_set_ssl_certificates(opt, dry_run, &mut err); - }, - ("set-url-map", Some(opt)) => { - call_result = self._target_https_proxies_set_url_map(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("target-https-proxies".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("target-instances", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._target_instances_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._target_instances_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._target_instances_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._target_instances_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._target_instances_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("target-instances".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("target-pools", Some(opt)) => { - match opt.subcommand() { - ("add-health-check", Some(opt)) => { - call_result = self._target_pools_add_health_check(opt, dry_run, &mut err); - }, - ("add-instance", Some(opt)) => { - call_result = self._target_pools_add_instance(opt, dry_run, &mut err); - }, - ("aggregated-list", Some(opt)) => { - call_result = self._target_pools_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._target_pools_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._target_pools_get(opt, dry_run, &mut err); - }, - ("get-health", Some(opt)) => { - call_result = self._target_pools_get_health(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._target_pools_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._target_pools_list(opt, dry_run, &mut err); - }, - ("remove-health-check", Some(opt)) => { - call_result = self._target_pools_remove_health_check(opt, dry_run, &mut err); - }, - ("remove-instance", Some(opt)) => { - call_result = self._target_pools_remove_instance(opt, dry_run, &mut err); - }, - ("set-backup", Some(opt)) => { - call_result = self._target_pools_set_backup(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("target-pools".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("target-ssl-proxies", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._target_ssl_proxies_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._target_ssl_proxies_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._target_ssl_proxies_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._target_ssl_proxies_list(opt, dry_run, &mut err); - }, - ("set-backend-service", Some(opt)) => { - call_result = self._target_ssl_proxies_set_backend_service(opt, dry_run, &mut err); - }, - ("set-proxy-header", Some(opt)) => { - call_result = self._target_ssl_proxies_set_proxy_header(opt, dry_run, &mut err); - }, - ("set-ssl-certificates", Some(opt)) => { - call_result = self._target_ssl_proxies_set_ssl_certificates(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("target-ssl-proxies".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("target-vpn-gateways", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._target_vpn_gateways_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._target_vpn_gateways_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._target_vpn_gateways_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._target_vpn_gateways_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._target_vpn_gateways_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("target-vpn-gateways".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("url-maps", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._url_maps_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._url_maps_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._url_maps_insert(opt, dry_run, &mut err); - }, - ("invalidate-cache", Some(opt)) => { - call_result = self._url_maps_invalidate_cache(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._url_maps_list(opt, dry_run, &mut err); - }, - ("patch", Some(opt)) => { - call_result = self._url_maps_patch(opt, dry_run, &mut err); - }, - ("update", Some(opt)) => { - call_result = self._url_maps_update(opt, dry_run, &mut err); - }, - ("validate", Some(opt)) => { - call_result = self._url_maps_validate(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("url-maps".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("vpn-tunnels", Some(opt)) => { - match opt.subcommand() { - ("aggregated-list", Some(opt)) => { - call_result = self._vpn_tunnels_aggregated_list(opt, dry_run, &mut err); - }, - ("delete", Some(opt)) => { - call_result = self._vpn_tunnels_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._vpn_tunnels_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._vpn_tunnels_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._vpn_tunnels_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("vpn-tunnels".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("zone-operations", Some(opt)) => { - match opt.subcommand() { - ("delete", Some(opt)) => { - call_result = self._zone_operations_delete(opt, dry_run, &mut err); - }, - ("get", Some(opt)) => { - call_result = self._zone_operations_get(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._zone_operations_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("zone-operations".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("zones", Some(opt)) => { - match opt.subcommand() { - ("get", Some(opt)) => { - call_result = self._zones_get(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._zones_list(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("zones".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - _ => { - err.issues.push(CLIError::MissingCommandError); - writeln!(io::stderr(), "{}\n", self.opt.usage()).ok(); - } - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - Err(err_opt) - } else { - Ok(call_result) - } - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: ArgMatches<'n>) -> Result, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "compute1-secret.json", - "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, - if opt.is_present("debug-auth") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }, - JsonTokenStorage { - program_name: "compute1", - db_dir: config_dir.clone(), - }, Some(FlowType::InstalledRedirect(54324))); - - let client = - if opt.is_present("debug") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }; - let engine = Engine { - opt: opt, - hub: api::Compute::new(client, auth), - gp: vec!["alt", "fields", "key", "oauth-token", "pretty-print", "quota-user", "user-ip"], - gpm: vec![ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ] - }; - - match engine._doit(true) { - Err(Some(err)) => Err(err), - Err(None) => Ok(engine), - Ok(_) => unreachable!(), - } - } - - fn doit(&self) -> Result<(), DoitError> { - match self._doit(false) { - Ok(res) => res, - Err(_) => unreachable!(), - } - } -} - -fn main() { - let mut exit_status = 0i32; - let arg_data = [ - ("addresses", "methods: 'aggregated-list', 'delete', 'get', 'insert' and 'list'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of addresses."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/addresses_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified address resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/addresses_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"address"##), - None, - Some(r##"Name of the address resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified address resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/addresses_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"address"##), - None, - Some(r##"Name of the address resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates an address resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/addresses_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of addresses contained within the specified region."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/addresses_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("autoscalers", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of autoscalers."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified autoscaler."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"autoscaler"##), - None, - Some(r##"Name of the autoscaler to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified autoscaler resource. Get a list of available autoscalers by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"autoscaler"##), - None, - Some(r##"Name of the autoscaler to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates an autoscaler in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of autoscalers contained within the specified zone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("patch", - Some(r##"Updates an autoscaler in the specified project using the data included in the request. This method supports patch semantics."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_patch", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"autoscaler"##), - None, - Some(r##"Name of the autoscaler to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("update", - Some(r##"Updates an autoscaler in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_update", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("backend-services", "methods: 'delete', 'get', 'get-health', 'insert', 'list', 'patch' and 'update'", vec![ - ("delete", - Some(r##"Deletes the specified BackendService resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"backend-service"##), - None, - Some(r##"Name of the BackendService resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified BackendService resource. Get a list of available backend services by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"backend-service"##), - None, - Some(r##"Name of the BackendService resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get-health", - Some(r##"Gets the most recent health check results for this BackendService."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_get-health", - vec![ - (Some(r##"project"##), - None, - None, - Some(true), - Some(false)), - - (Some(r##"backend-service"##), - None, - Some(r##"Name of the BackendService resource to which the queried instance belongs."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a BackendService resource in the specified project using the data included in the request. There are several restrictions and guidelines to keep in mind when creating a backend service. Read Restrictions and Guidelines for more information."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of BackendService resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("patch", - Some(r##"Updates the entire content of the BackendService resource. There are several restrictions and guidelines to keep in mind when updating a backend service. Read Restrictions and Guidelines for more information. This method supports patch semantics."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_patch", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"backend-service"##), - None, - Some(r##"Name of the BackendService resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("update", - Some(r##"Updates the entire content of the BackendService resource. There are several restrictions and guidelines to keep in mind when updating a backend service. Read Restrictions and Guidelines for more information."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_update", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"backend-service"##), - None, - Some(r##"Name of the BackendService resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("disk-types", "methods: 'aggregated-list', 'get' and 'list'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of disk types."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disk-types_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified disk type. Get a list of available disk types by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disk-types_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"disk-type"##), - None, - Some(r##"Name of the disk type to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of disk types available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disk-types_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("disks", "methods: 'aggregated-list', 'create-snapshot', 'delete', 'get', 'insert', 'list' and 'resize'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of persistent disks."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("create-snapshot", - Some(r##"Creates a snapshot of a specified persistent disk."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_create-snapshot", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"disk"##), - None, - Some(r##"Name of the persistent disk to snapshot."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"disk"##), - None, - Some(r##"Name of the persistent disk to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns a specified persistent disk. Get a list of available persistent disks by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"disk"##), - None, - Some(r##"Name of the persistent disk to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a persistent disk in the specified project using the data in the request. You can create a disk with a sourceImage, a sourceSnapshot, or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of persistent disks contained within the specified zone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("resize", - Some(r##"Resizes the specified persistent disk."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_resize", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"disk"##), - None, - Some(r##"The name of the persistent disk."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("firewalls", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ - ("delete", - Some(r##"Deletes the specified firewall."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"firewall"##), - None, - Some(r##"Name of the firewall rule to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified firewall."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"firewall"##), - None, - Some(r##"Name of the firewall rule to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a firewall rule in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of firewall rules available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("patch", - Some(r##"Updates the specified firewall rule with the data included in the request. This method supports patch semantics."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_patch", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"firewall"##), - None, - Some(r##"Name of the firewall rule to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("update", - Some(r##"Updates the specified firewall rule with the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_update", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"firewall"##), - None, - Some(r##"Name of the firewall rule to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("forwarding-rules", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'list' and 'set-target'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of forwarding rules."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified ForwardingRule resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"forwarding-rule"##), - None, - Some(r##"Name of the ForwardingRule resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified ForwardingRule resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"forwarding-rule"##), - None, - Some(r##"Name of the ForwardingRule resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a ForwardingRule resource in the specified project and region using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of ForwardingRule resources available to the specified project and region."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-target", - Some(r##"Changes target URL for forwarding rule. The new target should be of the same type as the old target."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_set-target", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"forwarding-rule"##), - None, - Some(r##"Name of the ForwardingRule resource in which target is to be set."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("global-addresses", "methods: 'delete', 'get', 'insert' and 'list'", vec![ - ("delete", - Some(r##"Deletes the specified address resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-addresses_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"address"##), - None, - Some(r##"Name of the address resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified address resource. Get a list of available addresses by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-addresses_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"address"##), - None, - Some(r##"Name of the address resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates an address resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-addresses_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of global addresses."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-addresses_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("global-forwarding-rules", "methods: 'delete', 'get', 'insert', 'list' and 'set-target'", vec![ - ("delete", - Some(r##"Deletes the specified ForwardingRule resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"forwarding-rule"##), - None, - Some(r##"Name of the ForwardingRule resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified ForwardingRule resource. Get a list of available forwarding rules by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"forwarding-rule"##), - None, - Some(r##"Name of the ForwardingRule resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a ForwardingRule resource in the specified project and region using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of ForwardingRule resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-target", - Some(r##"Changes target URL for forwarding rule. The new target should be of the same type as the old target."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_set-target", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"forwarding-rule"##), - None, - Some(r##"Name of the ForwardingRule resource in which target is to be set."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("global-operations", "methods: 'aggregated-list', 'delete', 'get' and 'list'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of all operations."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-operations_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified Operations resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-operations_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"operation"##), - None, - Some(r##"Name of the Operations resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - ]), - ("get", - Some(r##"Retrieves the specified Operations resource. Get a list of operations by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-operations_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"operation"##), - None, - Some(r##"Name of the Operations resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of Operation resources contained within the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-operations_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("health-checks", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ - ("delete", - Some(r##"Deletes the specified HealthCheck resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"health-check"##), - None, - Some(r##"Name of the HealthCheck resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified HealthCheck resource. Get a list of available health checks by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"health-check"##), - None, - Some(r##"Name of the HealthCheck resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a HealthCheck resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of HealthCheck resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("patch", - Some(r##"Updates a HealthCheck resource in the specified project using the data included in the request. This method supports patch semantics."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_patch", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"health-check"##), - None, - Some(r##"Name of the HealthCheck resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("update", - Some(r##"Updates a HealthCheck resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_update", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"health-check"##), - None, - Some(r##"Name of the HealthCheck resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("http-health-checks", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ - ("delete", - Some(r##"Deletes the specified HttpHealthCheck resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"http-health-check"##), - None, - Some(r##"Name of the HttpHealthCheck resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified HttpHealthCheck resource. Get a list of available HTTP health checks by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"http-health-check"##), - None, - Some(r##"Name of the HttpHealthCheck resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a HttpHealthCheck resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of HttpHealthCheck resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("patch", - Some(r##"Updates a HttpHealthCheck resource in the specified project using the data included in the request. This method supports patch semantics."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_patch", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"http-health-check"##), - None, - Some(r##"Name of the HttpHealthCheck resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("update", - Some(r##"Updates a HttpHealthCheck resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_update", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"http-health-check"##), - None, - Some(r##"Name of the HttpHealthCheck resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("https-health-checks", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ - ("delete", - Some(r##"Deletes the specified HttpsHealthCheck resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"https-health-check"##), - None, - Some(r##"Name of the HttpsHealthCheck resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified HttpsHealthCheck resource. Get a list of available HTTPS health checks by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"https-health-check"##), - None, - Some(r##"Name of the HttpsHealthCheck resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a HttpsHealthCheck resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of HttpsHealthCheck resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("patch", - Some(r##"Updates a HttpsHealthCheck resource in the specified project using the data included in the request. This method supports patch semantics."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_patch", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"https-health-check"##), - None, - Some(r##"Name of the HttpsHealthCheck resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("update", - Some(r##"Updates a HttpsHealthCheck resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_update", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"https-health-check"##), - None, - Some(r##"Name of the HttpsHealthCheck resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("images", "methods: 'delete', 'deprecate', 'get', 'get-from-family', 'insert' and 'list'", vec![ - ("delete", - Some(r##"Deletes the specified image."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"image"##), - None, - Some(r##"Name of the image resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("deprecate", - Some(r##"Sets the deprecation status of an image. - - If an empty request body is given, clears the deprecation status instead."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_deprecate", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"image"##), - None, - Some(r##"Image name."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified image. Get a list of available images by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"image"##), - None, - Some(r##"Name of the image resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get-from-family", - Some(r##"Returns the latest image that is part of an image family and is not deprecated."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_get-from-family", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"family"##), - None, - Some(r##"Name of the image family to search for."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates an image in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of private images available to the specified project. Private images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("instance-group-managers", "methods: 'abandon-instances', 'aggregated-list', 'delete', 'delete-instances', 'get', 'insert', 'list', 'list-managed-instances', 'recreate-instances', 'resize', 'set-instance-template' and 'set-target-pools'", vec![ - ("abandon-instances", - Some(r##"Schedules a group action to remove the specified instances from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_abandon-instances", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the managed instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group-manager"##), - None, - Some(r##"The name of the managed instance group."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("aggregated-list", - Some(r##"Retrieves the list of managed instance groups and groups them by zone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the managed instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group-manager"##), - None, - Some(r##"The name of the managed instance group to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete-instances", - Some(r##"Schedules a group action to delete the specified instances in the managed instance group. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_delete-instances", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the managed instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group-manager"##), - None, - Some(r##"The name of the managed instance group."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns all of the details about the specified managed instance group. Get a list of available managed instance groups by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the managed instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group-manager"##), - None, - Some(r##"The name of the managed instance group."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a managed instance group using the information that you specify in the request. After the group is created, it schedules an action to create instances in the group using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where you want to create the managed instance group."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of managed instance groups that are contained within the specified project and zone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the managed instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list-managed-instances", - Some(r##"Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_list-managed-instances", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the managed instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group-manager"##), - None, - Some(r##"The name of the managed instance group."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("recreate-instances", - Some(r##"Schedules a group action to recreate the specified instances in the managed instance group. The instances are deleted and recreated using the current instance template for the managed instance group. This operation is marked as DONE when the action is scheduled even if the instances have not yet been recreated. You must separately verify the status of the recreating action with the listmanagedinstances method."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_recreate-instances", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the managed instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group-manager"##), - None, - Some(r##"The name of the managed instance group."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("resize", - Some(r##"Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_resize", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the managed instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group-manager"##), - None, - Some(r##"The name of the managed instance group."##), - Some(true), - Some(false)), - - (Some(r##"size"##), - None, - Some(r##"The number of running instances that the managed instance group should maintain at any given time. The group automatically adds or removes instances to maintain the number of instances specified by this parameter."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-instance-template", - Some(r##"Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you recreate them."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_set-instance-template", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the managed instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group-manager"##), - None, - Some(r##"The name of the managed instance group."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-target-pools", - Some(r##"Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_set-target-pools", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the managed instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group-manager"##), - None, - Some(r##"The name of the managed instance group."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("instance-groups", "methods: 'add-instances', 'aggregated-list', 'delete', 'get', 'insert', 'list', 'list-instances', 'remove-instances' and 'set-named-ports'", vec![ - ("add-instances", - Some(r##"Adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_add-instances", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group"##), - None, - Some(r##"The name of the instance group where you are adding instances."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("aggregated-list", - Some(r##"Retrieves the list of instance groups and sorts them by zone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group"##), - None, - Some(r##"The name of the instance group to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified instance group. Get a list of available instance groups by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group"##), - None, - Some(r##"The name of the instance group."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates an instance group in the specified project using the parameters that are included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where you want to create the instance group."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of instance groups that are located in the specified project and zone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list-instances", - Some(r##"Lists the instances in the specified instance group."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_list-instances", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group"##), - None, - Some(r##"The name of the instance group from which you want to generate a list of included instances."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("remove-instances", - Some(r##"Removes one or more instances from the specified instance group, but does not delete those instances."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_remove-instances", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group"##), - None, - Some(r##"The name of the instance group where the specified instances will be removed."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-named-ports", - Some(r##"Sets the named ports for the specified instance group."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_set-named-ports", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone where the instance group is located."##), - Some(true), - Some(false)), - - (Some(r##"instance-group"##), - None, - Some(r##"The name of the instance group where the named ports are updated."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("instance-templates", "methods: 'delete', 'get', 'insert' and 'list'", vec![ - ("delete", - Some(r##"Deletes the specified instance template. If you delete an instance template that is being referenced from another instance group, the instance group will not be able to create or recreate virtual machine instances. Deleting an instance template is permanent and cannot be undone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance-template"##), - None, - Some(r##"The name of the instance template to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified instance template. Get a list of available instance templates by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance-template"##), - None, - Some(r##"The name of the instance template."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates an instance template in the specified project using the data that is included in the request. If you are creating a new template to update an existing instance group, your new instance template must use the same network or, if applicable, the same subnetwork as the original template."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of instance templates that are contained within the specified project and zone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("instances", "methods: 'add-access-config', 'aggregated-list', 'attach-disk', 'delete', 'delete-access-config', 'detach-disk', 'get', 'get-serial-port-output', 'insert', 'list', 'reset', 'set-disk-auto-delete', 'set-machine-type', 'set-metadata', 'set-scheduling', 'set-tags', 'start', 'start-with-encryption-key' and 'stop'", vec![ - ("add-access-config", - Some(r##"Adds an access config to an instance's network interface."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_add-access-config", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"The instance name for this request."##), - Some(true), - Some(false)), - - (Some(r##"network-interface"##), - None, - Some(r##"The name of the network interface to add to this instance."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("aggregated-list", - Some(r##"Retrieves aggregated list of instances."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("attach-disk", - Some(r##"Attaches a Disk resource to an instance."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_attach-disk", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"The instance name for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified Instance resource. For more information, see Stopping or Deleting an Instance."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Name of the instance resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete-access-config", - Some(r##"Deletes an access config from an instance's network interface."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_delete-access-config", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"The instance name for this request."##), - Some(true), - Some(false)), - - (Some(r##"access-config"##), - None, - Some(r##"The name of the access config to delete."##), - Some(true), - Some(false)), - - (Some(r##"network-interface"##), - None, - Some(r##"The name of the network interface."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("detach-disk", - Some(r##"Detaches a disk from an instance."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_detach-disk", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Instance name."##), - Some(true), - Some(false)), - - (Some(r##"device-name"##), - None, - Some(r##"Disk device name to detach."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified Instance resource. Get a list of available instances by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Name of the instance resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get-serial-port-output", - Some(r##"Returns the specified instance's serial port output."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_get-serial-port-output", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Name of the instance scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates an instance resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of instances contained within the specified zone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("reset", - Some(r##"Performs a hard reset on the instance."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_reset", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Name of the instance scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-disk-auto-delete", - Some(r##"Sets the auto-delete flag for a disk attached to an instance."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-disk-auto-delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"The instance name."##), - Some(true), - Some(false)), - - (Some(r##"auto-delete"##), - None, - Some(r##"Whether to auto-delete the disk when the instance is deleted."##), - Some(true), - Some(false)), - - (Some(r##"device-name"##), - None, - Some(r##"The device name of the disk to modify."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-machine-type", - Some(r##"Changes the machine type for a stopped instance to the machine type specified in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-machine-type", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Name of the instance scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-metadata", - Some(r##"Sets metadata for the specified instance to the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-metadata", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Name of the instance scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-scheduling", - Some(r##"Sets an instance's scheduling options."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-scheduling", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Instance name."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-tags", - Some(r##"Sets tags for the specified instance to the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-tags", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Name of the instance scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("start", - Some(r##"Starts an instance that was stopped using the using the instances().stop method. For more information, see Restart an instance."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_start", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Name of the instance resource to start."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("start-with-encryption-key", - Some(r##"Starts an instance that was stopped using the using the instances().stop method. For more information, see Restart an instance."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_start-with-encryption-key", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Name of the instance resource to start."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("stop", - Some(r##"Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur per-minute, virtual machine usage charges while they are stopped, but any resources that the virtual machine is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_stop", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"instance"##), - None, - Some(r##"Name of the instance resource to stop."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("licenses", "methods: 'get'", vec![ - ("get", - Some(r##"Returns the specified License resource. Get a list of available licenses by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/licenses_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"license"##), - None, - Some(r##"Name of the License resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("machine-types", "methods: 'aggregated-list', 'get' and 'list'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of machine types."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-types_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified machine type. Get a list of available machine types by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-types_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"machine-type"##), - None, - Some(r##"Name of the machine type to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of machine types available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-types_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"The name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("networks", "methods: 'delete', 'get', 'insert' and 'list'", vec![ - ("delete", - Some(r##"Deletes the specified network."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"network"##), - None, - Some(r##"Name of the network to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified network. Get a list of available networks by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"network"##), - None, - Some(r##"Name of the network to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a network in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of networks available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("projects", "methods: 'get', 'move-disk', 'move-instance', 'set-common-instance-metadata' and 'set-usage-export-bucket'", vec![ - ("get", - Some(r##"Returns the specified Project resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("move-disk", - Some(r##"Moves a persistent disk from one zone to another."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_move-disk", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("move-instance", - Some(r##"Moves an instance and its attached persistent disks from one zone to another."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_move-instance", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-common-instance-metadata", - Some(r##"Sets metadata common to all instances within the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_set-common-instance-metadata", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-usage-export-bucket", - Some(r##"Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide an empty request body using this method, the usage export feature will be disabled."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_set-usage-export-bucket", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("region-operations", "methods: 'delete', 'get' and 'list'", vec![ - ("delete", - Some(r##"Deletes the specified region-specific Operations resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-operations_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"operation"##), - None, - Some(r##"Name of the Operations resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - ]), - ("get", - Some(r##"Retrieves the specified region-specific Operations resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-operations_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"operation"##), - None, - Some(r##"Name of the Operations resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of Operation resources contained within the specified region."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-operations_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("regions", "methods: 'get' and 'list'", vec![ - ("get", - Some(r##"Returns the specified Region resource. Get a list of available regions by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/regions_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of region resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/regions_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("routers", "methods: 'aggregated-list', 'delete', 'get', 'get-router-status', 'insert', 'list', 'patch', 'preview' and 'update'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of routers."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified Router resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"router"##), - None, - Some(r##"Name of the Router resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified Router resource. Get a list of available routers by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"router"##), - None, - Some(r##"Name of the Router resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get-router-status", - Some(r##"Retrieves runtime information of the specified router."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_get-router-status", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"router"##), - None, - Some(r##"Name of the Router resource to query."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a Router resource in the specified project and region using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of Router resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("patch", - Some(r##"Updates the entire content of the Router resource. This method supports patch semantics."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_patch", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"router"##), - None, - Some(r##"Name of the Router resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("preview", - Some(r##"Preview fields auto-generated during router create and update operations. Calling this method does NOT create or update the router."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_preview", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"router"##), - None, - Some(r##"Name of the Router resource to query."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("update", - Some(r##"Updates the entire content of the Router resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_update", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"router"##), - None, - Some(r##"Name of the Router resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("routes", "methods: 'delete', 'get', 'insert' and 'list'", vec![ - ("delete", - Some(r##"Deletes the specified Route resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routes_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"route"##), - None, - Some(r##"Name of the Route resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified Route resource. Get a list of available routes by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routes_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"route"##), - None, - Some(r##"Name of the Route resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a Route resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routes_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of Route resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routes_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("snapshots", "methods: 'delete', 'get' and 'list'", vec![ - ("delete", - Some(r##"Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot. - - For more information, see Deleting snaphots."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"snapshot"##), - None, - Some(r##"Name of the Snapshot resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified Snapshot resource. Get a list of available snapshots by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"snapshot"##), - None, - Some(r##"Name of the Snapshot resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of Snapshot resources contained within the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("ssl-certificates", "methods: 'delete', 'get', 'insert' and 'list'", vec![ - ("delete", - Some(r##"Deletes the specified SslCertificate resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-certificates_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"ssl-certificate"##), - None, - Some(r##"Name of the SslCertificate resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified SslCertificate resource. Get a list of available SSL certificates by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-certificates_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"ssl-certificate"##), - None, - Some(r##"Name of the SslCertificate resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a SslCertificate resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-certificates_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of SslCertificate resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-certificates_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("subnetworks", "methods: 'aggregated-list', 'delete', 'get', 'insert' and 'list'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of subnetworks."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified subnetwork."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"subnetwork"##), - None, - Some(r##"Name of the Subnetwork resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified subnetwork. Get a list of available subnetworks list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"subnetwork"##), - None, - Some(r##"Name of the Subnetwork resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a subnetwork in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of subnetworks available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("target-http-proxies", "methods: 'delete', 'get', 'insert', 'list' and 'set-url-map'", vec![ - ("delete", - Some(r##"Deletes the specified TargetHttpProxy resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-http-proxy"##), - None, - Some(r##"Name of the TargetHttpProxy resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified TargetHttpProxy resource. Get a list of available target HTTP proxies by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-http-proxy"##), - None, - Some(r##"Name of the TargetHttpProxy resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a TargetHttpProxy resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of TargetHttpProxy resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-url-map", - Some(r##"Changes the URL map for TargetHttpProxy."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_set-url-map", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-http-proxy"##), - None, - Some(r##"Name of the TargetHttpProxy to set a URL map for."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("target-https-proxies", "methods: 'delete', 'get', 'insert', 'list', 'set-ssl-certificates' and 'set-url-map'", vec![ - ("delete", - Some(r##"Deletes the specified TargetHttpsProxy resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-https-proxy"##), - None, - Some(r##"Name of the TargetHttpsProxy resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified TargetHttpsProxy resource. Get a list of available target HTTPS proxies by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-https-proxy"##), - None, - Some(r##"Name of the TargetHttpsProxy resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a TargetHttpsProxy resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of TargetHttpsProxy resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-ssl-certificates", - Some(r##"Replaces SslCertificates for TargetHttpsProxy."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_set-ssl-certificates", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-https-proxy"##), - None, - Some(r##"Name of the TargetHttpsProxy resource to set an SslCertificates resource for."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-url-map", - Some(r##"Changes the URL map for TargetHttpsProxy."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_set-url-map", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-https-proxy"##), - None, - Some(r##"Name of the TargetHttpsProxy resource whose URL map is to be set."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("target-instances", "methods: 'aggregated-list', 'delete', 'get', 'insert' and 'list'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of target instances."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-instances_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified TargetInstance resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-instances_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"target-instance"##), - None, - Some(r##"Name of the TargetInstance resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified TargetInstance resource. Get a list of available target instances by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-instances_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"target-instance"##), - None, - Some(r##"Name of the TargetInstance resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a TargetInstance resource in the specified project and zone using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-instances_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of TargetInstance resources available to the specified project and zone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-instances_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("target-pools", "methods: 'add-health-check', 'add-instance', 'aggregated-list', 'delete', 'get', 'get-health', 'insert', 'list', 'remove-health-check', 'remove-instance' and 'set-backup'", vec![ - ("add-health-check", - Some(r##"Adds health check URLs to a target pool."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_add-health-check", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"target-pool"##), - None, - Some(r##"Name of the target pool to add a health check to."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("add-instance", - Some(r##"Adds an instance to a target pool."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_add-instance", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"target-pool"##), - None, - Some(r##"Name of the TargetPool resource to add instances to."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("aggregated-list", - Some(r##"Retrieves an aggregated list of target pools."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified target pool."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"target-pool"##), - None, - Some(r##"Name of the TargetPool resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified target pool. Get a list of available target pools by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"target-pool"##), - None, - Some(r##"Name of the TargetPool resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get-health", - Some(r##"Gets the most recent health check results for each IP for the instance that is referenced by the given target pool."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_get-health", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"target-pool"##), - None, - Some(r##"Name of the TargetPool resource to which the queried instance belongs."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a target pool in the specified project and region using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of target pools available to the specified project and region."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("remove-health-check", - Some(r##"Removes health check URL from a target pool."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_remove-health-check", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-pool"##), - None, - Some(r##"Name of the target pool to remove health checks from."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("remove-instance", - Some(r##"Removes instance URL from a target pool."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_remove-instance", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"target-pool"##), - None, - Some(r##"Name of the TargetPool resource to remove instances from."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-backup", - Some(r##"Changes a backup target pool's configurations."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_set-backup", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"target-pool"##), - None, - Some(r##"Name of the TargetPool resource to set a backup pool for."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("target-ssl-proxies", "methods: 'delete', 'get', 'insert', 'list', 'set-backend-service', 'set-proxy-header' and 'set-ssl-certificates'", vec![ - ("delete", - Some(r##"Deletes the specified TargetSslProxy resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-ssl-proxy"##), - None, - Some(r##"Name of the TargetSslProxy resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified TargetSslProxy resource. Get a list of available target SSL proxies by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-ssl-proxy"##), - None, - Some(r##"Name of the TargetSslProxy resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a TargetSslProxy resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of TargetSslProxy resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-backend-service", - Some(r##"Changes the BackendService for TargetSslProxy."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_set-backend-service", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-ssl-proxy"##), - None, - Some(r##"Name of the TargetSslProxy resource whose BackendService resource is to be set."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-proxy-header", - Some(r##"Changes the ProxyHeaderType for TargetSslProxy."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_set-proxy-header", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-ssl-proxy"##), - None, - Some(r##"Name of the TargetSslProxy resource whose ProxyHeader is to be set."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("set-ssl-certificates", - Some(r##"Changes SslCertificates for TargetSslProxy."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_set-ssl-certificates", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-ssl-proxy"##), - None, - Some(r##"Name of the TargetSslProxy resource whose SslCertificate resource is to be set."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("target-vpn-gateways", "methods: 'aggregated-list', 'delete', 'get', 'insert' and 'list'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of target VPN gateways."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-vpn-gateways_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified target VPN gateway."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-vpn-gateways_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-vpn-gateway"##), - None, - Some(r##"Name of the target VPN gateway to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified target VPN gateway. Get a list of available target VPN gateways by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-vpn-gateways_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"target-vpn-gateway"##), - None, - Some(r##"Name of the target VPN gateway to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a target VPN gateway in the specified project and region using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-vpn-gateways_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of target VPN gateways available to the specified project and region."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-vpn-gateways_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("url-maps", "methods: 'delete', 'get', 'insert', 'invalidate-cache', 'list', 'patch', 'update' and 'validate'", vec![ - ("delete", - Some(r##"Deletes the specified UrlMap resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"url-map"##), - None, - Some(r##"Name of the UrlMap resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified UrlMap resource. Get a list of available URL maps by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"url-map"##), - None, - Some(r##"Name of the UrlMap resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a UrlMap resource in the specified project using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("invalidate-cache", - Some(r##"Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_invalidate-cache", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"url-map"##), - None, - Some(r##"Name of the UrlMap scoping this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of UrlMap resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("patch", - Some(r##"Updates the entire content of the UrlMap resource. This method supports patch semantics."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_patch", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"url-map"##), - None, - Some(r##"Name of the UrlMap resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("update", - Some(r##"Updates the entire content of the UrlMap resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_update", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"url-map"##), - None, - Some(r##"Name of the UrlMap resource to update."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("validate", - Some(r##"Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_validate", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"url-map"##), - None, - Some(r##"Name of the UrlMap resource to be validated as."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("vpn-tunnels", "methods: 'aggregated-list', 'delete', 'get', 'insert' and 'list'", vec![ - ("aggregated-list", - Some(r##"Retrieves an aggregated list of VPN tunnels."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-tunnels_aggregated-list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("delete", - Some(r##"Deletes the specified VpnTunnel resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-tunnels_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"vpn-tunnel"##), - None, - Some(r##"Name of the VpnTunnel resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("get", - Some(r##"Returns the specified VpnTunnel resource. Get a list of available VPN tunnels by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-tunnels_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"vpn-tunnel"##), - None, - Some(r##"Name of the VpnTunnel resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a VpnTunnel resource in the specified project and region using the data included in the request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-tunnels_insert", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of VpnTunnel resources contained in the specified project and region."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-tunnels_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"region"##), - None, - Some(r##"Name of the region for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("zone-operations", "methods: 'delete', 'get' and 'list'", vec![ - ("delete", - Some(r##"Deletes the specified zone-specific Operations resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zone-operations_delete", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"operation"##), - None, - Some(r##"Name of the Operations resource to delete."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - ]), - ("get", - Some(r##"Retrieves the specified zone-specific Operations resource."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zone-operations_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone for this request."##), - Some(true), - Some(false)), - - (Some(r##"operation"##), - None, - Some(r##"Name of the Operations resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves a list of Operation resources contained within the specified zone."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zone-operations_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone for request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("zones", "methods: 'get' and 'list'", vec![ - ("get", - Some(r##"Returns the specified Zone resource. Get a list of available zones by making a list() request."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zones_get", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"zone"##), - None, - Some(r##"Name of the zone resource to return."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Retrieves the list of Zone resources available to the specified project."##), - "Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zones_list", - vec![ - (Some(r##"project"##), - None, - Some(r##"Project ID for this request."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ]; - - let mut app = App::new("compute1") - .author("Sebastian Thiel ") - .version("0.3.6+20160908") - .about("Creates and runs virtual machines on Google Cloud Platform.") - .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_compute1_cli") - .arg(Arg::with_name("url") - .long("scope") - .help("Specify the authentication a method should be executed in. Each scope requires the user to grant this application permission to use it.If unset, it defaults to the shortest scope url for a particular method.") - .multiple(true) - .takes_value(true)) - .arg(Arg::with_name("folder") - .long("config-dir") - .help("A directory into which we will store our persistent data. Defaults to a user-writable directory that we will create during the first invocation.[default: ~/.google-service-cli") - .multiple(false) - .takes_value(true)) - .arg(Arg::with_name("debug") - .long("debug") - .help("Output all server communication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)) - .arg(Arg::with_name("debug-auth") - .long("debug-auth") - .help("Output all communication related to authentication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)); - - for &(main_command_name, about, ref subcommands) in arg_data.iter() { - let mut mcmd = SubCommand::with_name(main_command_name).about(about); - - for &(sub_command_name, ref desc, url_info, ref args) in subcommands { - let mut scmd = SubCommand::with_name(sub_command_name); - if let &Some(desc) = desc { - scmd = scmd.about(desc); - } - scmd = scmd.after_help(url_info); - - for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args { - let arg_name_str = - match (arg_name, flag) { - (&Some(an), _ ) => an, - (_ , &Some(f)) => f, - _ => unreachable!(), - }; - let mut arg = Arg::with_name(arg_name_str) - .empty_values(false); - if let &Some(short_flag) = flag { - arg = arg.short(short_flag); - } - if let &Some(desc) = desc { - arg = arg.help(desc); - } - if arg_name.is_some() && flag.is_some() { - arg = arg.takes_value(true); - } - if let &Some(required) = required { - arg = arg.required(required); - } - if let &Some(multi) = multi { - arg = arg.multiple(multi); - } - scmd = scmd.arg(arg); - } - mcmd = mcmd.subcommand(scmd); - } - app = app.subcommand(mcmd); - } - - let matches = app.get_matches(); - - let debug = matches.is_present("debug"); - match Engine::new(matches) { - Err(err) => { - exit_status = err.exit_code; - writeln!(io::stderr(), "{}", err).ok(); - }, - Ok(engine) => { - if let Err(doit_err) = engine.doit() { - exit_status = 1; - match doit_err { - DoitError::IoError(path, err) => { - writeln!(io::stderr(), "Failed to open output file '{}': {}", path, err).ok(); - }, - DoitError::ApiError(err) => { - if debug { - writeln!(io::stderr(), "{:#?}", err).ok(); - } else { - writeln!(io::stderr(), "{}", err).ok(); - } - } - } - } - } - } - - std::process::exit(exit_status); -} \ No newline at end of file diff --git a/gen/compute1/Cargo.toml b/gen/compute1/Cargo.toml deleted file mode 100644 index ef544dc2a7..0000000000 --- a/gen/compute1/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-compute1" -version = "0.1.15+20160908" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with compute (protocol v1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/compute1" -homepage = "https://developers.google.com/compute/docs/reference/latest/" -documentation = "http://byron.github.io/google-apis-rs/google_compute1" -license = "MIT" -keywords = ["compute", "google", "protocol", "web", "api"] -build = "src/build.rs" - - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.8" -serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } -url = "= 0.5" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.8", optional = true } - diff --git a/gen/compute1/LICENSE.md b/gen/compute1/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/compute1/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/compute1/README.md b/gen/compute1/README.md deleted file mode 100644 index 601739bf5a..0000000000 --- a/gen/compute1/README.md +++ /dev/null @@ -1,369 +0,0 @@ - -The `google-compute1` library allows access to all features of the *Google compute* service. - -This documentation was generated from *compute* crate version *0.1.15+20160908*, where *20160908* is the exact revision of the *compute:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.15*. - -Everything else about the *compute* *v1* API can be found at the -[official documentation site](https://developers.google.com/compute/docs/reference/latest/). -# Features - -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_compute1/struct.Compute.html) ... - -* addresses - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.AddresseAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.AddresseDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.AddresseGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.AddresseInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.AddresseListCall.html) -* [autoscalers](http://byron.github.io/google-apis-rs/google_compute1/struct.Autoscaler.html) - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.AutoscalerAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.AutoscalerDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.AutoscalerGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.AutoscalerInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.AutoscalerListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_compute1/struct.AutoscalerPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_compute1/struct.AutoscalerUpdateCall.html) -* [backend services](http://byron.github.io/google-apis-rs/google_compute1/struct.BackendService.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.BackendServiceDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.BackendServiceGetCall.html), [*get health*](http://byron.github.io/google-apis-rs/google_compute1/struct.BackendServiceGetHealthCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.BackendServiceInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.BackendServiceListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_compute1/struct.BackendServicePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_compute1/struct.BackendServiceUpdateCall.html) -* [disk types](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskType.html) - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskTypeAggregatedListCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskTypeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskTypeListCall.html) -* [disks](http://byron.github.io/google-apis-rs/google_compute1/struct.Disk.html) - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskAggregatedListCall.html), [*create snapshot*](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskCreateSnapshotCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskListCall.html) and [*resize*](http://byron.github.io/google-apis-rs/google_compute1/struct.DiskResizeCall.html) -* [firewalls](http://byron.github.io/google-apis-rs/google_compute1/struct.Firewall.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.FirewallDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.FirewallGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.FirewallInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.FirewallListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_compute1/struct.FirewallPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_compute1/struct.FirewallUpdateCall.html) -* [forwarding rules](http://byron.github.io/google-apis-rs/google_compute1/struct.ForwardingRule.html) - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.ForwardingRuleAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.ForwardingRuleDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.ForwardingRuleGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.ForwardingRuleInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.ForwardingRuleListCall.html) and [*set target*](http://byron.github.io/google-apis-rs/google_compute1/struct.ForwardingRuleSetTargetCall.html) -* global addresses - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalAddresseDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalAddresseGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalAddresseInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalAddresseListCall.html) -* global forwarding rules - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalForwardingRuleDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalForwardingRuleGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalForwardingRuleInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalForwardingRuleListCall.html) and [*set target*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalForwardingRuleSetTargetCall.html) -* global operations - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalOperationAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalOperationDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalOperationGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.GlobalOperationListCall.html) -* [health checks](http://byron.github.io/google-apis-rs/google_compute1/struct.HealthCheck.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.HealthCheckDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.HealthCheckGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.HealthCheckInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.HealthCheckListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_compute1/struct.HealthCheckPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_compute1/struct.HealthCheckUpdateCall.html) -* [http health checks](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpHealthCheck.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpHealthCheckDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpHealthCheckGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpHealthCheckInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpHealthCheckListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpHealthCheckPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpHealthCheckUpdateCall.html) -* [https health checks](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpsHealthCheck.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpsHealthCheckDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpsHealthCheckGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpsHealthCheckInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpsHealthCheckListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpsHealthCheckPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_compute1/struct.HttpsHealthCheckUpdateCall.html) -* [images](http://byron.github.io/google-apis-rs/google_compute1/struct.Image.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.ImageDeleteCall.html), [*deprecate*](http://byron.github.io/google-apis-rs/google_compute1/struct.ImageDeprecateCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.ImageGetCall.html), [*get from family*](http://byron.github.io/google-apis-rs/google_compute1/struct.ImageGetFromFamilyCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.ImageInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.ImageListCall.html) -* [instance group managers](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManager.html) - * [*abandon instances*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerAbandonInstanceCall.html), [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerDeleteCall.html), [*delete instances*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerDeleteInstanceCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerListCall.html), [*list managed instances*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerListManagedInstanceCall.html), [*recreate instances*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerRecreateInstanceCall.html), [*resize*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerResizeCall.html), [*set instance template*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerSetInstanceTemplateCall.html) and [*set target pools*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupManagerSetTargetPoolCall.html) -* [instance groups](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroup.html) - * [*add instances*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupAddInstanceCall.html), [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupListCall.html), [*list instances*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupListInstanceCall.html), [*remove instances*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupRemoveInstanceCall.html) and [*set named ports*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGroupSetNamedPortCall.html) -* [instance templates](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceTemplate.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceTemplateDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceTemplateGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceTemplateInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceTemplateListCall.html) -* [instances](http://byron.github.io/google-apis-rs/google_compute1/struct.Instance.html) - * [*add access config*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceAddAccessConfigCall.html), [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceAggregatedListCall.html), [*attach disk*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceAttachDiskCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceDeleteCall.html), [*delete access config*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceDeleteAccessConfigCall.html), [*detach disk*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceDetachDiskCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGetCall.html), [*get serial port output*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceGetSerialPortOutputCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceListCall.html), [*reset*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceResetCall.html), [*set disk auto delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceSetDiskAutoDeleteCall.html), [*set machine type*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceSetMachineTypeCall.html), [*set metadata*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceSetMetadataCall.html), [*set scheduling*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceSetSchedulingCall.html), [*set tags*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceSetTagCall.html), [*start*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceStartCall.html), [*start with encryption key*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceStartWithEncryptionKeyCall.html) and [*stop*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceStopCall.html) -* [licenses](http://byron.github.io/google-apis-rs/google_compute1/struct.License.html) - * [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.LicenseGetCall.html) -* [machine types](http://byron.github.io/google-apis-rs/google_compute1/struct.MachineType.html) - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.MachineTypeAggregatedListCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.MachineTypeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.MachineTypeListCall.html) -* [networks](http://byron.github.io/google-apis-rs/google_compute1/struct.Network.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.NetworkDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.NetworkGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.NetworkInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.NetworkListCall.html) -* [projects](http://byron.github.io/google-apis-rs/google_compute1/struct.Project.html) - * [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.ProjectGetCall.html), [*move disk*](http://byron.github.io/google-apis-rs/google_compute1/struct.ProjectMoveDiskCall.html), [*move instance*](http://byron.github.io/google-apis-rs/google_compute1/struct.ProjectMoveInstanceCall.html), [*set common instance metadata*](http://byron.github.io/google-apis-rs/google_compute1/struct.ProjectSetCommonInstanceMetadataCall.html) and [*set usage export bucket*](http://byron.github.io/google-apis-rs/google_compute1/struct.ProjectSetUsageExportBucketCall.html) -* region operations - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.RegionOperationDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.RegionOperationGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.RegionOperationListCall.html) -* [regions](http://byron.github.io/google-apis-rs/google_compute1/struct.Region.html) - * [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.RegionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.RegionListCall.html) -* [routers](http://byron.github.io/google-apis-rs/google_compute1/struct.Router.html) - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouterAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouterDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouterGetCall.html), [*get router status*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouterGetRouterStatuCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouterInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouterListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouterPatchCall.html), [*preview*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouterPreviewCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouterUpdateCall.html) -* [routes](http://byron.github.io/google-apis-rs/google_compute1/struct.Route.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouteDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouteGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouteInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.RouteListCall.html) -* [snapshots](http://byron.github.io/google-apis-rs/google_compute1/struct.Snapshot.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.SnapshotDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.SnapshotGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.SnapshotListCall.html) -* [ssl certificates](http://byron.github.io/google-apis-rs/google_compute1/struct.SslCertificate.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.SslCertificateDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.SslCertificateGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.SslCertificateInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.SslCertificateListCall.html) -* [subnetworks](http://byron.github.io/google-apis-rs/google_compute1/struct.Subnetwork.html) - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.SubnetworkAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.SubnetworkDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.SubnetworkGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.SubnetworkInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.SubnetworkListCall.html) -* [target http proxies](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpProxy.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpProxyDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpProxyGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpProxyInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpProxyListCall.html) and [*set url map*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpProxySetUrlMapCall.html) -* [target https proxies](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpsProxy.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpsProxyDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpsProxyGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpsProxyInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpsProxyListCall.html), [*set ssl certificates*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpsProxySetSslCertificateCall.html) and [*set url map*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetHttpsProxySetUrlMapCall.html) -* [target instances](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetInstance.html) - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetInstanceAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetInstanceDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetInstanceGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetInstanceInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetInstanceListCall.html) -* [target pools](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPool.html) - * [*add health check*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolAddHealthCheckCall.html), [*add instance*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolAddInstanceCall.html), [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolGetCall.html), [*get health*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolGetHealthCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolListCall.html), [*remove health check*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolRemoveHealthCheckCall.html), [*remove instance*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolRemoveInstanceCall.html) and [*set backup*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetPoolSetBackupCall.html) -* [target ssl proxies](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetSslProxy.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetSslProxyDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetSslProxyGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetSslProxyInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetSslProxyListCall.html), [*set backend service*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetSslProxySetBackendServiceCall.html), [*set proxy header*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetSslProxySetProxyHeaderCall.html) and [*set ssl certificates*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetSslProxySetSslCertificateCall.html) -* [target vpn gateways](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetVpnGateway.html) - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetVpnGatewayAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetVpnGatewayDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetVpnGatewayGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetVpnGatewayInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.TargetVpnGatewayListCall.html) -* [url maps](http://byron.github.io/google-apis-rs/google_compute1/struct.UrlMap.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.UrlMapDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.UrlMapGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.UrlMapInsertCall.html), [*invalidate cache*](http://byron.github.io/google-apis-rs/google_compute1/struct.UrlMapInvalidateCacheCall.html), [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.UrlMapListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_compute1/struct.UrlMapPatchCall.html), [*update*](http://byron.github.io/google-apis-rs/google_compute1/struct.UrlMapUpdateCall.html) and [*validate*](http://byron.github.io/google-apis-rs/google_compute1/struct.UrlMapValidateCall.html) -* [vpn tunnels](http://byron.github.io/google-apis-rs/google_compute1/struct.VpnTunnel.html) - * [*aggregated list*](http://byron.github.io/google-apis-rs/google_compute1/struct.VpnTunnelAggregatedListCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.VpnTunnelDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.VpnTunnelGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_compute1/struct.VpnTunnelInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.VpnTunnelListCall.html) -* zone operations - * [*delete*](http://byron.github.io/google-apis-rs/google_compute1/struct.ZoneOperationDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.ZoneOperationGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.ZoneOperationListCall.html) -* [zones](http://byron.github.io/google-apis-rs/google_compute1/struct.Zone.html) - * [*get*](http://byron.github.io/google-apis-rs/google_compute1/struct.ZoneGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_compute1/struct.ZoneListCall.html) - - - - -# Structure of this Library - -The API is structured into the following primary items: - -* **[Hub](http://byron.github.io/google-apis-rs/google_compute1/struct.Compute.html)** - * a central object to maintain state and allow accessing all *Activities* - * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_compute1/trait.MethodsBuilder.html) which in turn - allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_compute1/trait.CallBuilder.html) -* **[Resources](http://byron.github.io/google-apis-rs/google_compute1/trait.Resource.html)** - * primary types that you can apply *Activities* to - * a collection of properties and *Parts* - * **[Parts](http://byron.github.io/google-apis-rs/google_compute1/trait.Part.html)** - * a collection of properties - * never directly used in *Activities* -* **[Activities](http://byron.github.io/google-apis-rs/google_compute1/trait.CallBuilder.html)** - * 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() -``` - -Or specifically ... - -```ignore -let r = hub.instance_group_managers().resize(...).doit() -let r = hub.ssl_certificates().delete(...).doit() -let r = hub.autoscalers().patch(...).doit() -let r = hub.target_https_proxies().delete(...).doit() -let r = hub.firewalls().patch(...).doit() -let r = hub.vpn_tunnels().delete(...).doit() -let r = hub.instances().set_machine_type(...).doit() -let r = hub.global_forwarding_rules().set_target(...).doit() -let r = hub.instances().insert(...).doit() -let r = hub.global_forwarding_rules().delete(...).doit() -let r = hub.vpn_tunnels().insert(...).doit() -let r = hub.disks().delete(...).doit() -let r = hub.instance_groups().add_instances(...).doit() -let r = hub.target_http_proxies().delete(...).doit() -let r = hub.instances().set_scheduling(...).doit() -let r = hub.instances().delete(...).doit() -let r = hub.target_pools().add_health_check(...).doit() -let r = hub.instance_group_managers().insert(...).doit() -let r = hub.global_addresses().insert(...).doit() -let r = hub.target_ssl_proxies().set_ssl_certificates(...).doit() -let r = hub.https_health_checks().delete(...).doit() -let r = hub.autoscalers().insert(...).doit() -let r = hub.instance_groups().insert(...).doit() -let r = hub.subnetworks().insert(...).doit() -let r = hub.instance_group_managers().delete_instances(...).doit() -let r = hub.target_ssl_proxies().set_backend_service(...).doit() -let r = hub.instance_group_managers().set_instance_template(...).doit() -let r = hub.disks().resize(...).doit() -let r = hub.target_pools().insert(...).doit() -let r = hub.instances().set_disk_auto_delete(...).doit() -let r = hub.instance_group_managers().set_target_pools(...).doit() -let r = hub.disks().insert(...).doit() -let r = hub.target_ssl_proxies().delete(...).doit() -let r = hub.https_health_checks().insert(...).doit() -let r = hub.target_pools().remove_health_check(...).doit() -let r = hub.target_https_proxies().set_url_map(...).doit() -let r = hub.backend_services().delete(...).doit() -let r = hub.url_maps().insert(...).doit() -let r = hub.instances().add_access_config(...).doit() -let r = hub.health_checks().patch(...).doit() -let r = hub.addresses().insert(...).doit() -let r = hub.health_checks().insert(...).doit() -let r = hub.global_forwarding_rules().insert(...).doit() -let r = hub.target_vpn_gateways().insert(...).doit() -let r = hub.addresses().delete(...).doit() -let r = hub.global_operations().get(...).doit() -let r = hub.disks().create_snapshot(...).doit() -let r = hub.health_checks().update(...).doit() -let r = hub.instance_groups().remove_instances(...).doit() -let r = hub.instances().set_metadata(...).doit() -let r = hub.forwarding_rules().insert(...).doit() -let r = hub.instances().start(...).doit() -let r = hub.instance_group_managers().delete(...).doit() -let r = hub.target_instances().insert(...).doit() -let r = hub.forwarding_rules().set_target(...).doit() -let r = hub.projects().move_disk(...).doit() -let r = hub.firewalls().insert(...).doit() -let r = hub.target_pools().set_backup(...).doit() -let r = hub.routes().insert(...).doit() -let r = hub.instance_groups().delete(...).doit() -let r = hub.instances().delete_access_config(...).doit() -let r = hub.target_https_proxies().set_ssl_certificates(...).doit() -let r = hub.networks().insert(...).doit() -let r = hub.instance_group_managers().abandon_instances(...).doit() -let r = hub.instances().set_tags(...).doit() -let r = hub.snapshots().delete(...).doit() -let r = hub.target_https_proxies().insert(...).doit() -let r = hub.instances().detach_disk(...).doit() -let r = hub.backend_services().update(...).doit() -let r = hub.instance_group_managers().recreate_instances(...).doit() -let r = hub.instances().attach_disk(...).doit() -let r = hub.projects().set_common_instance_metadata(...).doit() -let r = hub.region_operations().get(...).doit() -let r = hub.backend_services().patch(...).doit() -let r = hub.target_http_proxies().set_url_map(...).doit() -let r = hub.images().deprecate(...).doit() -let r = hub.http_health_checks().patch(...).doit() -let r = hub.images().insert(...).doit() -let r = hub.url_maps().invalidate_cache(...).doit() -let r = hub.instance_groups().set_named_ports(...).doit() -let r = hub.ssl_certificates().insert(...).doit() -let r = hub.projects().move_instance(...).doit() -let r = hub.autoscalers().delete(...).doit() -let r = hub.https_health_checks().update(...).doit() -let r = hub.url_maps().patch(...).doit() -let r = hub.subnetworks().delete(...).doit() -let r = hub.instances().stop(...).doit() -let r = hub.target_pools().add_instance(...).doit() -let r = hub.target_pools().remove_instance(...).doit() -let r = hub.target_pools().delete(...).doit() -let r = hub.firewalls().update(...).doit() -let r = hub.instance_templates().delete(...).doit() -let r = hub.projects().set_usage_export_bucket(...).doit() -let r = hub.target_http_proxies().insert(...).doit() -let r = hub.url_maps().update(...).doit() -let r = hub.instance_templates().insert(...).doit() -let r = hub.target_instances().delete(...).doit() -let r = hub.routers().delete(...).doit() -let r = hub.target_vpn_gateways().delete(...).doit() -let r = hub.health_checks().delete(...).doit() -let r = hub.global_addresses().delete(...).doit() -let r = hub.https_health_checks().patch(...).doit() -let r = hub.networks().delete(...).doit() -let r = hub.url_maps().delete(...).doit() -let r = hub.routers().insert(...).doit() -let r = hub.instances().reset(...).doit() -let r = hub.routers().update(...).doit() -let r = hub.routers().patch(...).doit() -let r = hub.backend_services().insert(...).doit() -let r = hub.target_ssl_proxies().set_proxy_header(...).doit() -let r = hub.http_health_checks().delete(...).doit() -let r = hub.http_health_checks().insert(...).doit() -let r = hub.images().delete(...).doit() -let r = hub.autoscalers().update(...).doit() -let r = hub.target_ssl_proxies().insert(...).doit() -let r = hub.instances().start_with_encryption_key(...).doit() -let r = hub.forwarding_rules().delete(...).doit() -let r = hub.firewalls().delete(...).doit() -let r = hub.zone_operations().get(...).doit() -let r = hub.http_health_checks().update(...).doit() -let r = hub.routes().delete(...).doit() -``` - -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-compute1 = "*" -``` - -## A complete example - -```Rust -extern crate hyper; -extern crate yup_oauth2 as oauth2; -extern crate google_compute1 as compute1; -use compute1::{Result, Error}; -use std::default::Default; -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use compute1::Compute; - -// Get an ApplicationSecret instance by some means. It contains the `client_id` and -// `client_secret`, among other things. -let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - ::default(), None); -let mut hub = Compute::new(hyper::Client::new(), auth); -// 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.instances().set_disk_auto_delete("project", "zone", "instance", true, "deviceName") - .doit(); - -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::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](http://byron.github.io/google-apis-rs/google_compute1/enum.Result.html) enumeration as return value of -the doit() methods, or handed as possibly intermediate results to either the -[Hub Delegate](http://byron.github.io/google-apis-rs/google_compute1/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_compute1/../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](http://byron.github.io/google-apis-rs/google_compute1/enum.Result.html), should be -read by you to obtain the media. -If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_compute1/trait.ResponseResult.html), 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](http://byron.github.io/google-apis-rs/google_compute1/trait.Delegate.html) to the -[Method Builder](http://byron.github.io/google-apis-rs/google_compute1/trait.CallBuilder.html) 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](http://byron.github.io/google-apis-rs/google_compute1/trait.Delegate.html) 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 [enocodable](http://byron.github.io/google-apis-rs/google_compute1/trait.RequestValue.html) and -[decodable](http://byron.github.io/google-apis-rs/google_compute1/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -are valid. -Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_compute1/trait.Part.html) 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](http://byron.github.io/google-apis-rs/google_compute1/trait.CallBuilder.html), 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](http://byron.github.io/google-apis-rs/google_compute1/trait.RequestValue.html) 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 **compute1** 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-rs/LICENSE.md diff --git a/gen/compute1/src/build.rs b/gen/compute1/src/build.rs deleted file mode 100644 index 0bebaf0bf0..0000000000 --- a/gen/compute1/src/build.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[cfg(feature = "with-serde-codegen")] -mod inner { - extern crate serde_codegen; - - use std::env; - use std::path::Path; - - pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - - let src = Path::new("src/lib.rs.in"); - let dst = Path::new(&out_dir).join("lib.rs"); - - serde_codegen::expand(&src, &dst).unwrap(); - } -} - -#[cfg(not(feature = "with-serde-codegen"))] -mod inner { - pub fn main() {} -} - -pub fn main() { - inner::main() -} \ No newline at end of file diff --git a/gen/compute1/src/cmn.rs b/gen/compute1/src/cmn.rs deleted file mode 100644 index d75063e466..0000000000 --- a/gen/compute1/src/cmn.rs +++ /dev/null @@ -1,753 +0,0 @@ -// COPY OF 'src/rust/api/cmn.rs' -// DO NOT EDIT -use std::io::{self, Read, Seek, Cursor, Write, SeekFrom}; -use std; -use std::fmt::{self, Display}; -use std::str::FromStr; -use std::error; -use std::thread::sleep; -use std::time::Duration; - -use mime::{Mime, TopLevel, SubLevel, Attr, Value}; -use oauth2::{TokenType, Retry, self}; -use hyper; -use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header, - HeaderFormat, Bearer}; -use hyper::http::h1::LINE_ENDING; -use hyper::method::Method; -use hyper::status::StatusCode; - -use serde_json as json; - -/// 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 {} -impl 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 utility type which can decode a server response that indicates error -#[derive(Deserialize)] -pub struct JsonServerError { - pub error: String, - pub error_description: Option -} - -/// A utility to represent detailed errors we might see in case there are BadRequests. -/// The latter happen if the sent parameters or request structures are unsound -#[derive(Deserialize, Serialize, Debug)] -pub struct ErrorResponse { - error: ServerError, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerError { - errors: Vec, - code: u16, - message: String, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerMessage { - domain: String, - reason: String, - message: String, - #[serde(rename="locationType")] - location_type: Option, - location: Option -} - -#[derive(Copy, Clone)] -pub struct DummyNetworkStream; - -impl Read for DummyNetworkStream { - fn read(&mut self, _: &mut [u8]) -> io::Result { - Ok(0) - } -} - -impl Write for DummyNetworkStream { - fn write(&mut self, _: &[u8]) -> io::Result { - Ok(0) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl hyper::net::NetworkStream for DummyNetworkStream { - fn peer_addr(&mut self) -> io::Result { - Ok("127.0.0.1:1337".parse().unwrap()) - } - - fn set_read_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } - - fn set_write_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } -} - - -/// 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 { - - /// 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, MethodInfo) {} - - /// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), 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, &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 { - 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: &error::Error) -> Option { - 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 { - 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::client::Response, Option, _: Option) -> 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(ErrorResponse), - - /// 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(Box), - - /// 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::client::Response), -} - - -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - 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 err) => { - try!(writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message)); - for err in err.error.errors.iter() { - try!(writeln!(f, " {}: {}, {}{}", - err.domain, - err.message, - err.reason, - match &err.location { - &Some(ref loc) => format!("@{}", loc), - &None => String::new(), - })); - } - 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 description(&self) -> &str { - match *self { - Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(_, ref err) => err.description(), - _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" - } - } - - fn cause(&self) -> Option<&error::Error> { - match *self { - Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(_, ref err) => err.cause(), - _ => None - } - } -} - -/// A universal result type used as return for all calls. -pub type Result = std::result::Result; - -/// Contains information about an API request. -pub struct MethodInfo { - pub id: &'static str, - pub http_method: Method, -} - -const BOUNDARY: &'static 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<(Headers, &'a mut Read)>, - current_part: Option<(Cursor>, &'a mut Read)>, - last_part_boundary: Option>>, -} - -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 Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> { - let mut headers = Headers::new(); - headers.set(ContentType(mime_type)); - headers.set(ContentLength(size)); - 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.len() == 0 && 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.len() == 0 && self.current_part.is_some() - } -} - -impl<'a> Read for MultiPartReader<'a> { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - 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::::new()); - (write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING, - headers, 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).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<'a>(&'a self) -> &'a Mime { &self.0 } -} -impl ::std::ops::DerefMut for XUploadContentType { - fn deref_mut<'a>(&'a mut self) -> &'a mut Mime { &mut self.0 } -} -impl Header for XUploadContentType { - fn header_name() -> &'static str { "X-Upload-Content-Type" } - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - hyper::header::parsing::from_one_raw_str(raw).map(XUploadContentType) - } -} -impl HeaderFormat for XUploadContentType { - fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&**self, f) - } -} -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 { - 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, - pub total_length: u64, -} - -impl Header for ContentRange { - fn header_name() -> &'static str { - "Content-Range" - } - - /// We are not parsable, as parsing is done by the `Range` header - fn parse_header(_: &[Vec]) -> hyper::error::Result { - Err(hyper::error::Error::Method) - } -} - - -impl HeaderFormat for ContentRange { - fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes ")); - match self.range { - Some(ref c) => try!(c.fmt(fmt)), - None => try!(fmt.write_str("*")) - } - (write!(fmt, "/{}", self.total_length)).ok(); - Ok(()) - } -} - -#[derive(Clone, PartialEq, Debug)] -pub struct RangeResponseHeader(pub Chunk); - -impl Header for RangeResponseHeader { - fn header_name() -> &'static str { - "Range" - } - - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - if raw.len() > 0 { - let v = &raw[0]; - if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes "; - if s.starts_with(PREFIX) { - if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { - return Ok(RangeResponseHeader(c)) - } - } - } - } - Err(hyper::error::Error::Method) - } -} - -impl HeaderFormat for RangeResponseHeader { - /// No implmentation necessary, we just need to parse - fn fmt_header(&self, _: &mut fmt::Formatter) -> fmt::Result { - Err(fmt::Error) - } -} - -/// A utility type to perform a resumable upload from start to end. -pub struct ResumableUploadHelper<'a, A: 'a> { - pub client: &'a mut hyper::client::Client, - pub delegate: &'a mut Delegate, - pub start_at: Option, - pub auth: &'a mut A, - pub user_agent: &'a str, - pub auth_header: Authorization, - pub url: &'a str, - pub reader: &'a mut ReadSeek, - pub media_type: Mime, - pub content_length: u64 -} - -impl<'a, A> ResumableUploadHelper<'a, A> - where A: oauth2::GetToken { - - fn query_transfer_status(&mut self) -> std::result::Result> { - loop { - match self.client.post(self.url) - .header(UserAgent(self.user_agent.to_string())) - .header(ContentRange { range: None, total_length: self.content_length }) - .header(self.auth_header.clone()) - .send() { - Ok(r) => { - // 308 = resume-incomplete == PermanentRedirect - let headers = r.headers.clone(); - let h: &RangeResponseHeader = match headers.get() { - Some(hh) if r.status == StatusCode::PermanentRedirect => hh, - None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None, 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 fn upload(&mut self) -> Option> { - let mut start = match self.start_at { - Some(s) => s, - None => match self.query_transfer_status() { - 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 - }; - - self.reader.seek(SeekFrom::Start(start)).unwrap(); - loop { - 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 range_header = ContentRange { - range: Some(Chunk {first: start, last: start + request_size - 1}), - total_length: self.content_length - }; - start += request_size; - if self.delegate.cancel_chunk_upload(&range_header) { - return None - } - let res = self.client.post(self.url) - .header(range_header) - .header(ContentType(self.media_type.clone())) - .header(UserAgent(self.user_agent.to_string())) - .body(&mut section_reader) - .send(); - match res { - Ok(mut res) => { - if res.status == StatusCode::PermanentRedirect { - continue - } - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - } - return Some(Ok(res)) - }, - Err(err) => { - if let Retry::After(d) = self.delegate.http_error(&err) { - sleep(d); - continue; - } - return Some(Err(err)) - } - } - } - } -} - -// Copy of src/rust/cli/cmn.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); - } - } - _ => {} - } -} diff --git a/gen/compute1/src/lib.rs b/gen/compute1/src/lib.rs deleted file mode 100644 index 5938138a9c..0000000000 --- a/gen/compute1/src/lib.rs +++ /dev/null @@ -1,379 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.mako' -// DO NOT EDIT ! - -//! This documentation was generated from *compute* crate version *0.1.15+20160908*, where *20160908* is the exact revision of the *compute:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.15*. -//! -//! Everything else about the *compute* *v1* API can be found at the -//! [official documentation site](https://developers.google.com/compute/docs/reference/latest/). -//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/compute1). -//! # Features -//! -//! Handle the following *Resources* with ease from the central [hub](struct.Compute.html) ... -//! -//! * addresses -//! * [*aggregated list*](struct.AddresseAggregatedListCall.html), [*delete*](struct.AddresseDeleteCall.html), [*get*](struct.AddresseGetCall.html), [*insert*](struct.AddresseInsertCall.html) and [*list*](struct.AddresseListCall.html) -//! * [autoscalers](struct.Autoscaler.html) -//! * [*aggregated list*](struct.AutoscalerAggregatedListCall.html), [*delete*](struct.AutoscalerDeleteCall.html), [*get*](struct.AutoscalerGetCall.html), [*insert*](struct.AutoscalerInsertCall.html), [*list*](struct.AutoscalerListCall.html), [*patch*](struct.AutoscalerPatchCall.html) and [*update*](struct.AutoscalerUpdateCall.html) -//! * [backend services](struct.BackendService.html) -//! * [*delete*](struct.BackendServiceDeleteCall.html), [*get*](struct.BackendServiceGetCall.html), [*get health*](struct.BackendServiceGetHealthCall.html), [*insert*](struct.BackendServiceInsertCall.html), [*list*](struct.BackendServiceListCall.html), [*patch*](struct.BackendServicePatchCall.html) and [*update*](struct.BackendServiceUpdateCall.html) -//! * [disk types](struct.DiskType.html) -//! * [*aggregated list*](struct.DiskTypeAggregatedListCall.html), [*get*](struct.DiskTypeGetCall.html) and [*list*](struct.DiskTypeListCall.html) -//! * [disks](struct.Disk.html) -//! * [*aggregated list*](struct.DiskAggregatedListCall.html), [*create snapshot*](struct.DiskCreateSnapshotCall.html), [*delete*](struct.DiskDeleteCall.html), [*get*](struct.DiskGetCall.html), [*insert*](struct.DiskInsertCall.html), [*list*](struct.DiskListCall.html) and [*resize*](struct.DiskResizeCall.html) -//! * [firewalls](struct.Firewall.html) -//! * [*delete*](struct.FirewallDeleteCall.html), [*get*](struct.FirewallGetCall.html), [*insert*](struct.FirewallInsertCall.html), [*list*](struct.FirewallListCall.html), [*patch*](struct.FirewallPatchCall.html) and [*update*](struct.FirewallUpdateCall.html) -//! * [forwarding rules](struct.ForwardingRule.html) -//! * [*aggregated list*](struct.ForwardingRuleAggregatedListCall.html), [*delete*](struct.ForwardingRuleDeleteCall.html), [*get*](struct.ForwardingRuleGetCall.html), [*insert*](struct.ForwardingRuleInsertCall.html), [*list*](struct.ForwardingRuleListCall.html) and [*set target*](struct.ForwardingRuleSetTargetCall.html) -//! * global addresses -//! * [*delete*](struct.GlobalAddresseDeleteCall.html), [*get*](struct.GlobalAddresseGetCall.html), [*insert*](struct.GlobalAddresseInsertCall.html) and [*list*](struct.GlobalAddresseListCall.html) -//! * global forwarding rules -//! * [*delete*](struct.GlobalForwardingRuleDeleteCall.html), [*get*](struct.GlobalForwardingRuleGetCall.html), [*insert*](struct.GlobalForwardingRuleInsertCall.html), [*list*](struct.GlobalForwardingRuleListCall.html) and [*set target*](struct.GlobalForwardingRuleSetTargetCall.html) -//! * global operations -//! * [*aggregated list*](struct.GlobalOperationAggregatedListCall.html), [*delete*](struct.GlobalOperationDeleteCall.html), [*get*](struct.GlobalOperationGetCall.html) and [*list*](struct.GlobalOperationListCall.html) -//! * [health checks](struct.HealthCheck.html) -//! * [*delete*](struct.HealthCheckDeleteCall.html), [*get*](struct.HealthCheckGetCall.html), [*insert*](struct.HealthCheckInsertCall.html), [*list*](struct.HealthCheckListCall.html), [*patch*](struct.HealthCheckPatchCall.html) and [*update*](struct.HealthCheckUpdateCall.html) -//! * [http health checks](struct.HttpHealthCheck.html) -//! * [*delete*](struct.HttpHealthCheckDeleteCall.html), [*get*](struct.HttpHealthCheckGetCall.html), [*insert*](struct.HttpHealthCheckInsertCall.html), [*list*](struct.HttpHealthCheckListCall.html), [*patch*](struct.HttpHealthCheckPatchCall.html) and [*update*](struct.HttpHealthCheckUpdateCall.html) -//! * [https health checks](struct.HttpsHealthCheck.html) -//! * [*delete*](struct.HttpsHealthCheckDeleteCall.html), [*get*](struct.HttpsHealthCheckGetCall.html), [*insert*](struct.HttpsHealthCheckInsertCall.html), [*list*](struct.HttpsHealthCheckListCall.html), [*patch*](struct.HttpsHealthCheckPatchCall.html) and [*update*](struct.HttpsHealthCheckUpdateCall.html) -//! * [images](struct.Image.html) -//! * [*delete*](struct.ImageDeleteCall.html), [*deprecate*](struct.ImageDeprecateCall.html), [*get*](struct.ImageGetCall.html), [*get from family*](struct.ImageGetFromFamilyCall.html), [*insert*](struct.ImageInsertCall.html) and [*list*](struct.ImageListCall.html) -//! * [instance group managers](struct.InstanceGroupManager.html) -//! * [*abandon instances*](struct.InstanceGroupManagerAbandonInstanceCall.html), [*aggregated list*](struct.InstanceGroupManagerAggregatedListCall.html), [*delete*](struct.InstanceGroupManagerDeleteCall.html), [*delete instances*](struct.InstanceGroupManagerDeleteInstanceCall.html), [*get*](struct.InstanceGroupManagerGetCall.html), [*insert*](struct.InstanceGroupManagerInsertCall.html), [*list*](struct.InstanceGroupManagerListCall.html), [*list managed instances*](struct.InstanceGroupManagerListManagedInstanceCall.html), [*recreate instances*](struct.InstanceGroupManagerRecreateInstanceCall.html), [*resize*](struct.InstanceGroupManagerResizeCall.html), [*set instance template*](struct.InstanceGroupManagerSetInstanceTemplateCall.html) and [*set target pools*](struct.InstanceGroupManagerSetTargetPoolCall.html) -//! * [instance groups](struct.InstanceGroup.html) -//! * [*add instances*](struct.InstanceGroupAddInstanceCall.html), [*aggregated list*](struct.InstanceGroupAggregatedListCall.html), [*delete*](struct.InstanceGroupDeleteCall.html), [*get*](struct.InstanceGroupGetCall.html), [*insert*](struct.InstanceGroupInsertCall.html), [*list*](struct.InstanceGroupListCall.html), [*list instances*](struct.InstanceGroupListInstanceCall.html), [*remove instances*](struct.InstanceGroupRemoveInstanceCall.html) and [*set named ports*](struct.InstanceGroupSetNamedPortCall.html) -//! * [instance templates](struct.InstanceTemplate.html) -//! * [*delete*](struct.InstanceTemplateDeleteCall.html), [*get*](struct.InstanceTemplateGetCall.html), [*insert*](struct.InstanceTemplateInsertCall.html) and [*list*](struct.InstanceTemplateListCall.html) -//! * [instances](struct.Instance.html) -//! * [*add access config*](struct.InstanceAddAccessConfigCall.html), [*aggregated list*](struct.InstanceAggregatedListCall.html), [*attach disk*](struct.InstanceAttachDiskCall.html), [*delete*](struct.InstanceDeleteCall.html), [*delete access config*](struct.InstanceDeleteAccessConfigCall.html), [*detach disk*](struct.InstanceDetachDiskCall.html), [*get*](struct.InstanceGetCall.html), [*get serial port output*](struct.InstanceGetSerialPortOutputCall.html), [*insert*](struct.InstanceInsertCall.html), [*list*](struct.InstanceListCall.html), [*reset*](struct.InstanceResetCall.html), [*set disk auto delete*](struct.InstanceSetDiskAutoDeleteCall.html), [*set machine type*](struct.InstanceSetMachineTypeCall.html), [*set metadata*](struct.InstanceSetMetadataCall.html), [*set scheduling*](struct.InstanceSetSchedulingCall.html), [*set tags*](struct.InstanceSetTagCall.html), [*start*](struct.InstanceStartCall.html), [*start with encryption key*](struct.InstanceStartWithEncryptionKeyCall.html) and [*stop*](struct.InstanceStopCall.html) -//! * [licenses](struct.License.html) -//! * [*get*](struct.LicenseGetCall.html) -//! * [machine types](struct.MachineType.html) -//! * [*aggregated list*](struct.MachineTypeAggregatedListCall.html), [*get*](struct.MachineTypeGetCall.html) and [*list*](struct.MachineTypeListCall.html) -//! * [networks](struct.Network.html) -//! * [*delete*](struct.NetworkDeleteCall.html), [*get*](struct.NetworkGetCall.html), [*insert*](struct.NetworkInsertCall.html) and [*list*](struct.NetworkListCall.html) -//! * [projects](struct.Project.html) -//! * [*get*](struct.ProjectGetCall.html), [*move disk*](struct.ProjectMoveDiskCall.html), [*move instance*](struct.ProjectMoveInstanceCall.html), [*set common instance metadata*](struct.ProjectSetCommonInstanceMetadataCall.html) and [*set usage export bucket*](struct.ProjectSetUsageExportBucketCall.html) -//! * region operations -//! * [*delete*](struct.RegionOperationDeleteCall.html), [*get*](struct.RegionOperationGetCall.html) and [*list*](struct.RegionOperationListCall.html) -//! * [regions](struct.Region.html) -//! * [*get*](struct.RegionGetCall.html) and [*list*](struct.RegionListCall.html) -//! * [routers](struct.Router.html) -//! * [*aggregated list*](struct.RouterAggregatedListCall.html), [*delete*](struct.RouterDeleteCall.html), [*get*](struct.RouterGetCall.html), [*get router status*](struct.RouterGetRouterStatuCall.html), [*insert*](struct.RouterInsertCall.html), [*list*](struct.RouterListCall.html), [*patch*](struct.RouterPatchCall.html), [*preview*](struct.RouterPreviewCall.html) and [*update*](struct.RouterUpdateCall.html) -//! * [routes](struct.Route.html) -//! * [*delete*](struct.RouteDeleteCall.html), [*get*](struct.RouteGetCall.html), [*insert*](struct.RouteInsertCall.html) and [*list*](struct.RouteListCall.html) -//! * [snapshots](struct.Snapshot.html) -//! * [*delete*](struct.SnapshotDeleteCall.html), [*get*](struct.SnapshotGetCall.html) and [*list*](struct.SnapshotListCall.html) -//! * [ssl certificates](struct.SslCertificate.html) -//! * [*delete*](struct.SslCertificateDeleteCall.html), [*get*](struct.SslCertificateGetCall.html), [*insert*](struct.SslCertificateInsertCall.html) and [*list*](struct.SslCertificateListCall.html) -//! * [subnetworks](struct.Subnetwork.html) -//! * [*aggregated list*](struct.SubnetworkAggregatedListCall.html), [*delete*](struct.SubnetworkDeleteCall.html), [*get*](struct.SubnetworkGetCall.html), [*insert*](struct.SubnetworkInsertCall.html) and [*list*](struct.SubnetworkListCall.html) -//! * [target http proxies](struct.TargetHttpProxy.html) -//! * [*delete*](struct.TargetHttpProxyDeleteCall.html), [*get*](struct.TargetHttpProxyGetCall.html), [*insert*](struct.TargetHttpProxyInsertCall.html), [*list*](struct.TargetHttpProxyListCall.html) and [*set url map*](struct.TargetHttpProxySetUrlMapCall.html) -//! * [target https proxies](struct.TargetHttpsProxy.html) -//! * [*delete*](struct.TargetHttpsProxyDeleteCall.html), [*get*](struct.TargetHttpsProxyGetCall.html), [*insert*](struct.TargetHttpsProxyInsertCall.html), [*list*](struct.TargetHttpsProxyListCall.html), [*set ssl certificates*](struct.TargetHttpsProxySetSslCertificateCall.html) and [*set url map*](struct.TargetHttpsProxySetUrlMapCall.html) -//! * [target instances](struct.TargetInstance.html) -//! * [*aggregated list*](struct.TargetInstanceAggregatedListCall.html), [*delete*](struct.TargetInstanceDeleteCall.html), [*get*](struct.TargetInstanceGetCall.html), [*insert*](struct.TargetInstanceInsertCall.html) and [*list*](struct.TargetInstanceListCall.html) -//! * [target pools](struct.TargetPool.html) -//! * [*add health check*](struct.TargetPoolAddHealthCheckCall.html), [*add instance*](struct.TargetPoolAddInstanceCall.html), [*aggregated list*](struct.TargetPoolAggregatedListCall.html), [*delete*](struct.TargetPoolDeleteCall.html), [*get*](struct.TargetPoolGetCall.html), [*get health*](struct.TargetPoolGetHealthCall.html), [*insert*](struct.TargetPoolInsertCall.html), [*list*](struct.TargetPoolListCall.html), [*remove health check*](struct.TargetPoolRemoveHealthCheckCall.html), [*remove instance*](struct.TargetPoolRemoveInstanceCall.html) and [*set backup*](struct.TargetPoolSetBackupCall.html) -//! * [target ssl proxies](struct.TargetSslProxy.html) -//! * [*delete*](struct.TargetSslProxyDeleteCall.html), [*get*](struct.TargetSslProxyGetCall.html), [*insert*](struct.TargetSslProxyInsertCall.html), [*list*](struct.TargetSslProxyListCall.html), [*set backend service*](struct.TargetSslProxySetBackendServiceCall.html), [*set proxy header*](struct.TargetSslProxySetProxyHeaderCall.html) and [*set ssl certificates*](struct.TargetSslProxySetSslCertificateCall.html) -//! * [target vpn gateways](struct.TargetVpnGateway.html) -//! * [*aggregated list*](struct.TargetVpnGatewayAggregatedListCall.html), [*delete*](struct.TargetVpnGatewayDeleteCall.html), [*get*](struct.TargetVpnGatewayGetCall.html), [*insert*](struct.TargetVpnGatewayInsertCall.html) and [*list*](struct.TargetVpnGatewayListCall.html) -//! * [url maps](struct.UrlMap.html) -//! * [*delete*](struct.UrlMapDeleteCall.html), [*get*](struct.UrlMapGetCall.html), [*insert*](struct.UrlMapInsertCall.html), [*invalidate cache*](struct.UrlMapInvalidateCacheCall.html), [*list*](struct.UrlMapListCall.html), [*patch*](struct.UrlMapPatchCall.html), [*update*](struct.UrlMapUpdateCall.html) and [*validate*](struct.UrlMapValidateCall.html) -//! * [vpn tunnels](struct.VpnTunnel.html) -//! * [*aggregated list*](struct.VpnTunnelAggregatedListCall.html), [*delete*](struct.VpnTunnelDeleteCall.html), [*get*](struct.VpnTunnelGetCall.html), [*insert*](struct.VpnTunnelInsertCall.html) and [*list*](struct.VpnTunnelListCall.html) -//! * zone operations -//! * [*delete*](struct.ZoneOperationDeleteCall.html), [*get*](struct.ZoneOperationGetCall.html) and [*list*](struct.ZoneOperationListCall.html) -//! * [zones](struct.Zone.html) -//! * [*get*](struct.ZoneGetCall.html) and [*list*](struct.ZoneListCall.html) -//! -//! -//! -//! -//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html). -//! -//! # Structure of this Library -//! -//! The API is structured into the following primary items: -//! -//! * **[Hub](struct.Compute.html)** -//! * a central object to maintain state and allow accessing all *Activities* -//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn -//! allow access to individual [*Call Builders*](trait.CallBuilder.html) -//! * **[Resources](trait.Resource.html)** -//! * primary types that you can apply *Activities* to -//! * a collection of properties and *Parts* -//! * **[Parts](trait.Part.html)** -//! * a collection of properties -//! * never directly used in *Activities* -//! * **[Activities](trait.CallBuilder.html)** -//! * 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() -//! ``` -//! -//! Or specifically ... -//! -//! ```ignore -//! let r = hub.instance_group_managers().resize(...).doit() -//! let r = hub.ssl_certificates().delete(...).doit() -//! let r = hub.autoscalers().patch(...).doit() -//! let r = hub.target_https_proxies().delete(...).doit() -//! let r = hub.firewalls().patch(...).doit() -//! let r = hub.vpn_tunnels().delete(...).doit() -//! let r = hub.instances().set_machine_type(...).doit() -//! let r = hub.global_forwarding_rules().set_target(...).doit() -//! let r = hub.instances().insert(...).doit() -//! let r = hub.global_forwarding_rules().delete(...).doit() -//! let r = hub.vpn_tunnels().insert(...).doit() -//! let r = hub.disks().delete(...).doit() -//! let r = hub.instance_groups().add_instances(...).doit() -//! let r = hub.target_http_proxies().delete(...).doit() -//! let r = hub.instances().set_scheduling(...).doit() -//! let r = hub.instances().delete(...).doit() -//! let r = hub.target_pools().add_health_check(...).doit() -//! let r = hub.instance_group_managers().insert(...).doit() -//! let r = hub.global_addresses().insert(...).doit() -//! let r = hub.target_ssl_proxies().set_ssl_certificates(...).doit() -//! let r = hub.https_health_checks().delete(...).doit() -//! let r = hub.autoscalers().insert(...).doit() -//! let r = hub.instance_groups().insert(...).doit() -//! let r = hub.subnetworks().insert(...).doit() -//! let r = hub.instance_group_managers().delete_instances(...).doit() -//! let r = hub.target_ssl_proxies().set_backend_service(...).doit() -//! let r = hub.instance_group_managers().set_instance_template(...).doit() -//! let r = hub.disks().resize(...).doit() -//! let r = hub.target_pools().insert(...).doit() -//! let r = hub.instances().set_disk_auto_delete(...).doit() -//! let r = hub.instance_group_managers().set_target_pools(...).doit() -//! let r = hub.disks().insert(...).doit() -//! let r = hub.target_ssl_proxies().delete(...).doit() -//! let r = hub.https_health_checks().insert(...).doit() -//! let r = hub.target_pools().remove_health_check(...).doit() -//! let r = hub.target_https_proxies().set_url_map(...).doit() -//! let r = hub.backend_services().delete(...).doit() -//! let r = hub.url_maps().insert(...).doit() -//! let r = hub.instances().add_access_config(...).doit() -//! let r = hub.health_checks().patch(...).doit() -//! let r = hub.addresses().insert(...).doit() -//! let r = hub.health_checks().insert(...).doit() -//! let r = hub.global_forwarding_rules().insert(...).doit() -//! let r = hub.target_vpn_gateways().insert(...).doit() -//! let r = hub.addresses().delete(...).doit() -//! let r = hub.global_operations().get(...).doit() -//! let r = hub.disks().create_snapshot(...).doit() -//! let r = hub.health_checks().update(...).doit() -//! let r = hub.instance_groups().remove_instances(...).doit() -//! let r = hub.instances().set_metadata(...).doit() -//! let r = hub.forwarding_rules().insert(...).doit() -//! let r = hub.instances().start(...).doit() -//! let r = hub.instance_group_managers().delete(...).doit() -//! let r = hub.target_instances().insert(...).doit() -//! let r = hub.forwarding_rules().set_target(...).doit() -//! let r = hub.projects().move_disk(...).doit() -//! let r = hub.firewalls().insert(...).doit() -//! let r = hub.target_pools().set_backup(...).doit() -//! let r = hub.routes().insert(...).doit() -//! let r = hub.instance_groups().delete(...).doit() -//! let r = hub.instances().delete_access_config(...).doit() -//! let r = hub.target_https_proxies().set_ssl_certificates(...).doit() -//! let r = hub.networks().insert(...).doit() -//! let r = hub.instance_group_managers().abandon_instances(...).doit() -//! let r = hub.instances().set_tags(...).doit() -//! let r = hub.snapshots().delete(...).doit() -//! let r = hub.target_https_proxies().insert(...).doit() -//! let r = hub.instances().detach_disk(...).doit() -//! let r = hub.backend_services().update(...).doit() -//! let r = hub.instance_group_managers().recreate_instances(...).doit() -//! let r = hub.instances().attach_disk(...).doit() -//! let r = hub.projects().set_common_instance_metadata(...).doit() -//! let r = hub.region_operations().get(...).doit() -//! let r = hub.backend_services().patch(...).doit() -//! let r = hub.target_http_proxies().set_url_map(...).doit() -//! let r = hub.images().deprecate(...).doit() -//! let r = hub.http_health_checks().patch(...).doit() -//! let r = hub.images().insert(...).doit() -//! let r = hub.url_maps().invalidate_cache(...).doit() -//! let r = hub.instance_groups().set_named_ports(...).doit() -//! let r = hub.ssl_certificates().insert(...).doit() -//! let r = hub.projects().move_instance(...).doit() -//! let r = hub.autoscalers().delete(...).doit() -//! let r = hub.https_health_checks().update(...).doit() -//! let r = hub.url_maps().patch(...).doit() -//! let r = hub.subnetworks().delete(...).doit() -//! let r = hub.instances().stop(...).doit() -//! let r = hub.target_pools().add_instance(...).doit() -//! let r = hub.target_pools().remove_instance(...).doit() -//! let r = hub.target_pools().delete(...).doit() -//! let r = hub.firewalls().update(...).doit() -//! let r = hub.instance_templates().delete(...).doit() -//! let r = hub.projects().set_usage_export_bucket(...).doit() -//! let r = hub.target_http_proxies().insert(...).doit() -//! let r = hub.url_maps().update(...).doit() -//! let r = hub.instance_templates().insert(...).doit() -//! let r = hub.target_instances().delete(...).doit() -//! let r = hub.routers().delete(...).doit() -//! let r = hub.target_vpn_gateways().delete(...).doit() -//! let r = hub.health_checks().delete(...).doit() -//! let r = hub.global_addresses().delete(...).doit() -//! let r = hub.https_health_checks().patch(...).doit() -//! let r = hub.networks().delete(...).doit() -//! let r = hub.url_maps().delete(...).doit() -//! let r = hub.routers().insert(...).doit() -//! let r = hub.instances().reset(...).doit() -//! let r = hub.routers().update(...).doit() -//! let r = hub.routers().patch(...).doit() -//! let r = hub.backend_services().insert(...).doit() -//! let r = hub.target_ssl_proxies().set_proxy_header(...).doit() -//! let r = hub.http_health_checks().delete(...).doit() -//! let r = hub.http_health_checks().insert(...).doit() -//! let r = hub.images().delete(...).doit() -//! let r = hub.autoscalers().update(...).doit() -//! let r = hub.target_ssl_proxies().insert(...).doit() -//! let r = hub.instances().start_with_encryption_key(...).doit() -//! let r = hub.forwarding_rules().delete(...).doit() -//! let r = hub.firewalls().delete(...).doit() -//! let r = hub.zone_operations().get(...).doit() -//! let r = hub.http_health_checks().update(...).doit() -//! let r = hub.routes().delete(...).doit() -//! ``` -//! -//! 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-compute1 = "*" -//! ``` -//! -//! ## A complete example -//! -//! ```test_harness,no_run -//! extern crate hyper; -//! extern crate yup_oauth2 as oauth2; -//! extern crate google_compute1 as compute1; -//! use compute1::{Result, Error}; -//! # #[test] fn egal() { -//! use std::default::Default; -//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use compute1::Compute; -//! -//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and -//! // `client_secret`, among other things. -//! let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -//! hyper::Client::new(), -//! ::default(), None); -//! let mut hub = Compute::new(hyper::Client::new(), auth); -//! // 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.instances().set_disk_auto_delete("project", "zone", "instance", false, "deviceName") -//! .doit(); -//! -//! 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::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](enum.Result.html) enumeration as return value of -//! the doit() methods, or handed as possibly intermediate results to either the -//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../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](enum.Result.html), should be -//! read by you to obtain the media. -//! If such a method also supports a [Response Result](trait.ResponseResult.html), 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](trait.Delegate.html) to the -//! [Method Builder](trait.CallBuilder.html) 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](trait.Delegate.html) 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 [enocodable](trait.RequestValue.html) and -//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -//! are valid. -//! Most optionals are are considered [Parts](trait.Part.html) 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](trait.CallBuilder.html), 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](trait.RequestValue.html) 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 ... . -#![cfg_attr(feature = "nightly", feature(custom_derive, custom_attribute, plugin))] -#![cfg_attr(feature = "nightly", plugin(serde_macros))] -#![allow(unused_imports, unused_mut, dead_code)] - -#[cfg(feature = "nightly")] -include!("lib.rs.in"); - -#[cfg(feature = "with-serde-codegen")] -include!(concat!(env!("OUT_DIR"), "/lib.rs")); \ No newline at end of file diff --git a/gen/compute1/src/lib.rs.in b/gen/compute1/src/lib.rs.in deleted file mode 100644 index 09bf03e508..0000000000 --- a/gen/compute1/src/lib.rs.in +++ /dev/null @@ -1,72885 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.in.mako' -// DO NOT EDIT ! - -extern crate hyper; -extern crate serde; -extern crate serde_json; -extern crate yup_oauth2 as oauth2; -extern crate mime; -extern crate url; - -mod cmn; - -use std::collections::HashMap; -use std::cell::RefCell; -use std::borrow::BorrowMut; -use std::default::Default; -use std::collections::BTreeMap; -use serde_json as json; -use std::io; -use std::fs; -use std::thread::sleep; -use std::time::Duration; - -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, - ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, - Resource, ErrorResponse, remove_json_null_values}; - - -// ############## -// UTILITIES ### -// ############ - -/// Identifies the an OAuth2 authorization scope. -/// A scope is needed when requesting an -/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). -#[derive(PartialEq, Eq, Hash)] -pub enum Scope { - /// View and manage your Google Compute Engine resources - Full, - - /// Manage your data and permissions in Google Cloud Storage - DevstorageFullControl, - - /// View your data in Google Cloud Storage - DevstorageReadOnly, - - /// Manage your data in Google Cloud Storage - DevstorageReadWrite, - - /// View and manage your data across Google Cloud Platform services - CloudPlatform, - - /// View your Google Compute Engine resources - Readonly, -} - -impl AsRef for Scope { - fn as_ref(&self) -> &str { - match *self { - Scope::Full => "https://www.googleapis.com/auth/compute", - Scope::DevstorageFullControl => "https://www.googleapis.com/auth/devstorage.full_control", - Scope::DevstorageReadOnly => "https://www.googleapis.com/auth/devstorage.read_only", - Scope::DevstorageReadWrite => "https://www.googleapis.com/auth/devstorage.read_write", - Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform", - Scope::Readonly => "https://www.googleapis.com/auth/compute.readonly", - } - } -} - -impl Default for Scope { - fn default() -> Scope { - Scope::Readonly - } -} - - - -// ######## -// HUB ### -// ###### - -/// Central instance to access all Compute related resource activities -/// -/// # Examples -/// -/// Instantiate a new hub -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// use compute1::{Result, Error}; -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and -/// // `client_secret`, among other things. -/// let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().set_disk_auto_delete("project", "zone", "instance", true, "deviceName") -/// .doit(); -/// -/// 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::MissingAPIKey -/// |Error::MissingToken(_) -/// |Error::Cancelled -/// |Error::UploadSizeLimitExceeded(_, _) -/// |Error::Failure(_) -/// |Error::BadRequest(_) -/// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_, _) => println!("{}", e), -/// }, -/// Ok(res) => println!("Success: {:?}", res), -/// } -/// # } -/// ``` -pub struct Compute { - client: RefCell, - auth: RefCell, - _user_agent: String, -} - -impl<'a, C, A> Hub for Compute {} - -impl<'a, C, A> Compute - where C: BorrowMut, A: oauth2::GetToken { - - pub fn new(client: C, authenticator: A) -> Compute { - Compute { - client: RefCell::new(client), - auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.15".to_string(), - } - } - - pub fn addresses(&'a self) -> AddresseMethods<'a, C, A> { - AddresseMethods { hub: &self } - } - pub fn autoscalers(&'a self) -> AutoscalerMethods<'a, C, A> { - AutoscalerMethods { hub: &self } - } - pub fn backend_services(&'a self) -> BackendServiceMethods<'a, C, A> { - BackendServiceMethods { hub: &self } - } - pub fn disk_types(&'a self) -> DiskTypeMethods<'a, C, A> { - DiskTypeMethods { hub: &self } - } - pub fn disks(&'a self) -> DiskMethods<'a, C, A> { - DiskMethods { hub: &self } - } - pub fn firewalls(&'a self) -> FirewallMethods<'a, C, A> { - FirewallMethods { hub: &self } - } - pub fn forwarding_rules(&'a self) -> ForwardingRuleMethods<'a, C, A> { - ForwardingRuleMethods { hub: &self } - } - pub fn global_addresses(&'a self) -> GlobalAddresseMethods<'a, C, A> { - GlobalAddresseMethods { hub: &self } - } - pub fn global_forwarding_rules(&'a self) -> GlobalForwardingRuleMethods<'a, C, A> { - GlobalForwardingRuleMethods { hub: &self } - } - pub fn global_operations(&'a self) -> GlobalOperationMethods<'a, C, A> { - GlobalOperationMethods { hub: &self } - } - pub fn health_checks(&'a self) -> HealthCheckMethods<'a, C, A> { - HealthCheckMethods { hub: &self } - } - pub fn http_health_checks(&'a self) -> HttpHealthCheckMethods<'a, C, A> { - HttpHealthCheckMethods { hub: &self } - } - pub fn https_health_checks(&'a self) -> HttpsHealthCheckMethods<'a, C, A> { - HttpsHealthCheckMethods { hub: &self } - } - pub fn images(&'a self) -> ImageMethods<'a, C, A> { - ImageMethods { hub: &self } - } - pub fn instance_group_managers(&'a self) -> InstanceGroupManagerMethods<'a, C, A> { - InstanceGroupManagerMethods { hub: &self } - } - pub fn instance_groups(&'a self) -> InstanceGroupMethods<'a, C, A> { - InstanceGroupMethods { hub: &self } - } - pub fn instance_templates(&'a self) -> InstanceTemplateMethods<'a, C, A> { - InstanceTemplateMethods { hub: &self } - } - pub fn instances(&'a self) -> InstanceMethods<'a, C, A> { - InstanceMethods { hub: &self } - } - pub fn licenses(&'a self) -> LicenseMethods<'a, C, A> { - LicenseMethods { hub: &self } - } - pub fn machine_types(&'a self) -> MachineTypeMethods<'a, C, A> { - MachineTypeMethods { hub: &self } - } - pub fn networks(&'a self) -> NetworkMethods<'a, C, A> { - NetworkMethods { hub: &self } - } - pub fn projects(&'a self) -> ProjectMethods<'a, C, A> { - ProjectMethods { hub: &self } - } - pub fn region_operations(&'a self) -> RegionOperationMethods<'a, C, A> { - RegionOperationMethods { hub: &self } - } - pub fn regions(&'a self) -> RegionMethods<'a, C, A> { - RegionMethods { hub: &self } - } - pub fn routers(&'a self) -> RouterMethods<'a, C, A> { - RouterMethods { hub: &self } - } - pub fn routes(&'a self) -> RouteMethods<'a, C, A> { - RouteMethods { hub: &self } - } - pub fn snapshots(&'a self) -> SnapshotMethods<'a, C, A> { - SnapshotMethods { hub: &self } - } - pub fn ssl_certificates(&'a self) -> SslCertificateMethods<'a, C, A> { - SslCertificateMethods { hub: &self } - } - pub fn subnetworks(&'a self) -> SubnetworkMethods<'a, C, A> { - SubnetworkMethods { hub: &self } - } - pub fn target_http_proxies(&'a self) -> TargetHttpProxyMethods<'a, C, A> { - TargetHttpProxyMethods { hub: &self } - } - pub fn target_https_proxies(&'a self) -> TargetHttpsProxyMethods<'a, C, A> { - TargetHttpsProxyMethods { hub: &self } - } - pub fn target_instances(&'a self) -> TargetInstanceMethods<'a, C, A> { - TargetInstanceMethods { hub: &self } - } - pub fn target_pools(&'a self) -> TargetPoolMethods<'a, C, A> { - TargetPoolMethods { hub: &self } - } - pub fn target_ssl_proxies(&'a self) -> TargetSslProxyMethods<'a, C, A> { - TargetSslProxyMethods { hub: &self } - } - pub fn target_vpn_gateways(&'a self) -> TargetVpnGatewayMethods<'a, C, A> { - TargetVpnGatewayMethods { hub: &self } - } - pub fn url_maps(&'a self) -> UrlMapMethods<'a, C, A> { - UrlMapMethods { hub: &self } - } - pub fn vpn_tunnels(&'a self) -> VpnTunnelMethods<'a, C, A> { - VpnTunnelMethods { hub: &self } - } - pub fn zone_operations(&'a self) -> ZoneOperationMethods<'a, C, A> { - ZoneOperationMethods { hub: &self } - } - pub fn zones(&'a self) -> ZoneMethods<'a, C, A> { - ZoneMethods { hub: &self } - } - - /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.15`. - /// - /// Returns the previously set user-agent. - pub fn user_agent(&mut self, agent_name: String) -> String { - let prev = self._user_agent.clone(); - self._user_agent = agent_name; - prev - } -} - - -// ############ -// SCHEMAS ### -// ########## -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct VpnTunnelsScopedList { - /// List of vpn tunnels contained in this scope. - #[serde(rename="vpnTunnels")] - pub vpn_tunnels: Option>, - /// Informational warning which replaces the list of addresses when the list is empty. - pub warning: Option, -} - -impl Part for VpnTunnelsScopedList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [resize disks](struct.DiskResizeCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DisksResizeRequest { - /// The new size of the persistent disk, which is specified in GB. - #[serde(rename="sizeGb")] - pub size_gb: Option, -} - -impl RequestValue for DisksResizeRequest {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ForwardingRulesScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for ForwardingRulesScopedListWarningData {} -impl Part for ForwardingRulesScopedListWarningData {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set named ports instance groups](struct.InstanceGroupSetNamedPortCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupsSetNamedPortsRequest { - /// The fingerprint of the named ports information for this instance group. Use this optional property to prevent conflicts when multiple users change the named ports settings concurrently. Obtain the fingerprint with the instanceGroups.get method. Then, include the fingerprint in your request to ensure that you do not overwrite changes that were applied from another concurrent request. - pub fingerprint: Option, - /// The list of named ports to set for this instance group. - #[serde(rename="namedPorts")] - pub named_ports: Option>, -} - -impl RequestValue for InstanceGroupsSetNamedPortsRequest {} - - -/// Contains a list of UrlMap resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list url maps](struct.UrlMapListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UrlMapList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of UrlMap resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] Unique identifier for the resource. Set by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for UrlMapList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set instance template instance group managers](struct.InstanceGroupManagerSetInstanceTemplateCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagersSetInstanceTemplateRequest { - /// The URL of the instance template that is specified for this managed instance group. The group uses this template to create all new instances in the managed instance group. - #[serde(rename="instanceTemplate")] - pub instance_template: Option, -} - -impl RequestValue for InstanceGroupManagersSetInstanceTemplateRequest {} - - -/// A DiskType resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list disk types](struct.DiskTypeAggregatedListCall.html) (none) -/// * [list disk types](struct.DiskTypeListCall.html) (none) -/// * [get disk types](struct.DiskTypeGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DiskType { - /// [Output Only] Type of the resource. Always compute#diskType for disk types. - pub kind: Option, - /// [Output Only] An optional description of this resource. - pub description: Option, - /// [Output Only] URL of the zone where the disk type resides. - pub zone: Option, - /// [Output Only] An optional textual description of the valid disk size, such as "10GB-10TB". - #[serde(rename="validDiskSize")] - pub valid_disk_size: Option, - /// [Output Only] The deprecation status associated with this disk type. - pub deprecated: Option, - /// [Output Only] Server-defined default disk size in GB. - #[serde(rename="defaultDiskSizeGb")] - pub default_disk_size_gb: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// [Output Only] Name of the resource. - pub name: Option, -} - -impl Resource for DiskType {} -impl ResponseResult for DiskType {} - - -/// A TargetSslProxy resource. This resource defines an SSL proxy. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get target ssl proxies](struct.TargetSslProxyGetCall.html) (response) -/// * [insert target ssl proxies](struct.TargetSslProxyInsertCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetSslProxy { - /// [Output Only] Type of the resource. Always compute#targetSslProxy for target SSL proxies. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// URL to the BackendService resource. - pub service: Option, - /// Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. - #[serde(rename="proxyHeader")] - pub proxy_header: Option, - /// URLs to SslCertificate resources that are used to authenticate connections to Backends. Currently exactly one SSL certificate must be specified. - #[serde(rename="sslCertificates")] - pub ssl_certificates: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, -} - -impl RequestValue for TargetSslProxy {} -impl ResponseResult for TargetSslProxy {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MachineTypesScopedList { - /// [Output Only] List of machine types contained in this scope. - #[serde(rename="machineTypes")] - pub machine_types: Option>, - /// [Output Only] An informational warning that appears when the machine types list is empty. - pub warning: Option, -} - -impl Part for MachineTypesScopedList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list vpn tunnels](struct.VpnTunnelAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct VpnTunnelAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A map of scoped vpn tunnel lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#vpnTunnel for VPN tunnels. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for VpnTunnelAggregatedList {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RoutersScopedList { - /// List of routers contained in this scope. - pub routers: Option>, - /// Informational warning which replaces the list of routers when the list is empty. - pub warning: Option, -} - -impl Part for RoutersScopedList {} - - -/// A metadata key/value entry. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set common instance metadata projects](struct.ProjectSetCommonInstanceMetadataCall.html) (request) -/// * [set metadata instances](struct.InstanceSetMetadataCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Metadata { - /// Array of key/value pairs. The total size of all keys and values must be less than 512 KB. - pub items: Option>, - /// [Output Only] Type of the resource. Always compute#metadata for metadata. - pub kind: Option, - /// Specifies a fingerprint for this request, which is essentially a hash of the metadata's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update metadata. You must always provide an up-to-date fingerprint hash in order to update or change metadata. - pub fingerprint: Option, -} - -impl RequestValue for Metadata {} - - -/// Contains a list of TargetHttpsProxy resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list target https proxies](struct.TargetHttpsProxyListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetHttpsProxyList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of TargetHttpsProxy resources. - pub items: Option>, - /// Type of resource. Always compute#targetHttpsProxyList for lists of target HTTPS proxies. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for TargetHttpsProxyList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [recreate instances instance group managers](struct.InstanceGroupManagerRecreateInstanceCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagersRecreateInstancesRequest { - /// The URL for one or more instances to recreate. - pub instances: Option>, -} - -impl RequestValue for InstanceGroupManagersRecreateInstancesRequest {} - - -/// [Output Only] The warning that replaces the list of managed instance groups when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagersScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for InstanceGroupManagersScopedListWarning {} -impl Part for InstanceGroupManagersScopedListWarning {} - - -/// [Output Only] If potential misconfigurations are detected for this route, this field will be populated with warning messages. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouteWarnings { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for RouteWarnings {} -impl Part for RouteWarnings {} - - -/// A TargetHttpProxy resource. This resource defines an HTTP proxy. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get target http proxies](struct.TargetHttpProxyGetCall.html) (response) -/// * [insert target http proxies](struct.TargetHttpProxyInsertCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetHttpProxy { - /// [Output Only] Type of resource. Always compute#targetHttpProxy for target HTTP proxies. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// URL to the UrlMap resource that defines the mapping from URL to the BackendService. - #[serde(rename="urlMap")] - pub url_map: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, -} - -impl RequestValue for TargetHttpProxy {} -impl ResponseResult for TargetHttpProxy {} - - -/// -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceProperties { - /// Enables instances created based on this template to send packets with source IP addresses other than their own and receive packets with destination IP addresses other than their own. If these instances will be used as an IP gateway or it will be set as the next-hop in a Route resource, specify true. If unsure, leave this set to false. See the Enable IP forwarding for instances documentation for more information. - #[serde(rename="canIpForward")] - pub can_ip_forward: Option, - /// An optional text description for the instances that are created from this instance template. - pub description: Option, - /// A list of tags to apply to the instances that are created from this template. The tags identify valid sources or targets for network firewalls. The setTags method can modify this list of tags. Each tag within the list must comply with RFC1035. - pub tags: Option, - /// An array of disks that are associated with the instances that are created from this template. - pub disks: Option>, - /// Specifies the scheduling options for the instances that are created from this template. - pub scheduling: Option, - /// The machine type to use for instances that are created from this template. - #[serde(rename="machineType")] - pub machine_type: Option, - /// A list of service accounts with specified scopes. Access tokens for these service accounts are available to the instances that are created from this template. Use metadata queries to obtain the access tokens for these instances. - #[serde(rename="serviceAccounts")] - pub service_accounts: Option>, - /// An array of network access configurations for this interface. - #[serde(rename="networkInterfaces")] - pub network_interfaces: Option>, - /// The metadata key/value pairs to assign to instances that are created from this template. These pairs can consist of custom metadata or predefined keys. See Project and instance metadata for more information. - pub metadata: Option, -} - -impl Part for InstanceProperties {} - - -/// [Output Only] If errors are generated during processing of the operation, this field will be populated. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperationError { - /// [Output Only] The array of errors encountered while processing this operation. - pub errors: Option>, -} - -impl NestedType for OperationError {} -impl Part for OperationError {} - - -/// Array of key/value pairs. The total size of all keys and values must be less than 512 KB. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MetadataItems { - /// Key for the metadata entry. Keys must conform to the following regexp: [a-zA-Z0-9-_]+, and be less than 128 bytes in length. This is reflected as part of a URL in the metadata server. Additionally, to avoid ambiguity, keys must not conflict with any other metadata keys for the project. - pub key: Option, - /// Value for the metadata entry. These are free-form strings, and only have meaning as interpreted by the image running in the instance. The only restriction placed on values is that their size must be less than or equal to 32768 bytes. - pub value: Option, -} - -impl NestedType for MetadataItems {} -impl Part for MetadataItems {} - - -/// Contains a list of addresses. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list addresses](struct.AddresseListCall.html) (response) -/// * [list global addresses](struct.GlobalAddresseListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AddressList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of addresses. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#addressList for lists of addresses. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for AddressList {} - - -/// Contains a list of HttpsHealthCheck resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list https health checks](struct.HttpsHealthCheckListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HttpsHealthCheckList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of HttpsHealthCheck resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for HttpsHealthCheckList {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceWithNamedPorts { - /// [Output Only] The status of the instance. - pub status: Option, - /// [Output Only] The URL of the instance. - pub instance: Option, - /// [Output Only] The named ports that belong to this instance group. - #[serde(rename="namedPorts")] - pub named_ports: Option>, -} - -impl Part for InstanceWithNamedPorts {} - - -/// [Output Only] Informational warning which replaces the list of addresses when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AddressesScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for AddressesScopedListWarning {} -impl Part for AddressesScopedListWarning {} - - -/// Message representing the validation result for a UrlMap. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UrlMapValidationResult { - /// no description provided - #[serde(rename="testFailures")] - pub test_failures: Option>, - /// no description provided - #[serde(rename="loadErrors")] - pub load_errors: Option>, - /// Whether the given UrlMap can be successfully loaded. If false, 'loadErrors' indicates the reasons. - #[serde(rename="loadSucceeded")] - pub load_succeeded: Option, - /// If successfully loaded, this field indicates whether the test passed. If false, 'testFailures's indicate the reason of failure. - #[serde(rename="testPassed")] - pub test_passed: Option, -} - -impl Part for UrlMapValidationResult {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagerActionsSummary { - /// [Output Only] The number of instances in the managed instance group that are running and have no scheduled actions. - pub none: Option, - /// [Output Only] The number of instances in the managed instance group that are scheduled to be recreated or are currently being being recreated. Recreating an instance deletes the existing root persistent disk and creates a new disk from the image that is defined in the instance template. - pub recreating: Option, - /// [Output Only] The number of instances in the managed instance group that are scheduled to be created or are currently being created. If the group fails to create any of these instances, it tries again until it creates the instance successfully. - /// - /// If you have disabled creation retries, this field will not be populated; instead, the creatingWithoutRetries field will be populated. - pub creating: Option, - /// [Output Only] The number of instances in the managed instance group that are scheduled to be restarted or are currently being restarted. - pub restarting: Option, - /// [Output Only] The total number of instances in the managed instance group that are scheduled to be abandoned. Abandoning an instance removes it from the managed instance group without deleting it. - pub abandoning: Option, - /// [Output Only] The number of instances in the managed instance group that are scheduled to be deleted or are currently being deleted. - pub deleting: Option, - /// [Output Only] The number of instances that the managed instance group will attempt to create. The group attempts to create each instance only once. If the group fails to create any of these instances, it decreases the group's target_size value accordingly. - #[serde(rename="creatingWithoutRetries")] - pub creating_without_retries: Option, - /// [Output Only] The number of instances in the managed instance group that are being reconfigured with properties that do not require a restart or a recreate action. For example, setting or removing target pools for the instance. - pub refreshing: Option, -} - -impl Part for InstanceGroupManagerActionsSummary {} - - -/// A matcher for the path portion of the URL. The BackendService from the longest-matched rule will serve the URL. If no rule was matched, the default service will be used. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PathMatcher { - /// The full or partial URL to the BackendService resource. This will be used if none of the pathRules defined by this PathMatcher is matched by the URL's path portion. For example, the following are all valid URLs to a BackendService resource: - /// - https://www.googleapis.com/compute/v1/projects/project/global/backendServices/backendService - /// - compute/v1/projects/project/global/backendServices/backendService - /// - global/backendServices/backendService - #[serde(rename="defaultService")] - pub default_service: Option, - /// The list of path rules. - #[serde(rename="pathRules")] - pub path_rules: Option>, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// The name to which this PathMatcher is referred by the HostRule. - pub name: Option, -} - -impl Part for PathMatcher {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ManagedInstanceLastAttempt { - /// [Output Only] Encountered errors during the last attempt to create or delete the instance. - pub errors: Option, -} - -impl Part for ManagedInstanceLastAttempt {} - - -/// Region resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list regions](struct.RegionListCall.html) (none) -/// * [get regions](struct.RegionGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Region { - /// [Output Only] Status of the region, either UP or DOWN. - pub status: Option, - /// [Output Only] Type of the resource. Always compute#region for regions. - pub kind: Option, - /// [Output Only] Textual description of the resource. - pub description: Option, - /// [Output Only] The deprecation status associated with this region. - pub deprecated: Option, - /// [Output Only] Quotas assigned to this region. - pub quotas: Option>, - /// [Output Only] A list of zones available in this region, in the form of resource URLs. - pub zones: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// [Output Only] Name of the resource. - pub name: Option, -} - -impl Resource for Region {} -impl ResponseResult for Region {} - - -/// A path-matching rule for a URL. If matched, will use the specified BackendService to handle the traffic arriving at this URL. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PathRule { - /// The list of path patterns to match. Each must start with / and the only place a * is allowed is at the end following a /. The string fed to the path matcher does not include any text after the first ? or #, and those chars are not allowed here. - pub paths: Option>, - /// The URL of the BackendService resource if this rule is matched. - pub service: Option, -} - -impl Part for PathRule {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HTTPHealthCheck { - /// Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence. - #[serde(rename="portName")] - pub port_name: Option, - /// The value of the host header in the HTTP health check request. If left empty (default value), the IP on behalf of which this health check is performed will be used. - pub host: Option, - /// Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. - #[serde(rename="proxyHeader")] - pub proxy_header: Option, - /// The TCP port number for the health check request. The default value is 80. - pub port: Option, - /// The request path of the HTTP health check request. The default value is /. - #[serde(rename="requestPath")] - pub request_path: Option, -} - -impl Part for HTTPHealthCheck {} - - -/// A Project resource. Projects can only be created in the Google Cloud Platform Console. Unless marked otherwise, values can only be modified in the console. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set common instance metadata projects](struct.ProjectSetCommonInstanceMetadataCall.html) (none) -/// * [set usage export bucket projects](struct.ProjectSetUsageExportBucketCall.html) (none) -/// * [move instance projects](struct.ProjectMoveInstanceCall.html) (none) -/// * [get projects](struct.ProjectGetCall.html) (response) -/// * [move disk projects](struct.ProjectMoveDiskCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Project { - /// [Output Only] Type of the resource. Always compute#project for projects. - pub kind: Option, - /// [Output Only] Default service account used by VMs running in this project. - #[serde(rename="defaultServiceAccount")] - pub default_service_account: Option, - /// An optional textual description of the resource. - pub description: Option, - /// Metadata key/value pairs available to all instances contained in this project. See Custom metadata for more information. - #[serde(rename="commonInstanceMetadata")] - pub common_instance_metadata: Option, - /// [Output Only] Quotas assigned to this project. - pub quotas: Option>, - /// The naming prefix for daily usage reports and the Google Cloud Storage bucket where they are stored. - #[serde(rename="usageExportLocation")] - pub usage_export_location: Option, - /// Restricted features enabled for use on this project. - #[serde(rename="enabledFeatures")] - pub enabled_features: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. This is not the project ID, and is just a unique ID used by Compute Engine to identify resources. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// The project ID. For example: my-example-project. Use the project ID to make requests to Compute Engine. - pub name: Option, -} - -impl Resource for Project {} -impl ResponseResult for Project {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list subnetworks](struct.SubnetworkAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SubnetworkAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output] A map of scoped Subnetwork lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#subnetworkAggregatedList for aggregated lists of subnetworks. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for SubnetworkAggregatedList {} - - -/// An Instance Group Manager resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list managed instances instance group managers](struct.InstanceGroupManagerListManagedInstanceCall.html) (none) -/// * [resize instance group managers](struct.InstanceGroupManagerResizeCall.html) (none) -/// * [aggregated list instance group managers](struct.InstanceGroupManagerAggregatedListCall.html) (none) -/// * [delete instances instance group managers](struct.InstanceGroupManagerDeleteInstanceCall.html) (none) -/// * [delete instance group managers](struct.InstanceGroupManagerDeleteCall.html) (none) -/// * [abandon instances instance group managers](struct.InstanceGroupManagerAbandonInstanceCall.html) (none) -/// * [get instance group managers](struct.InstanceGroupManagerGetCall.html) (response) -/// * [set instance template instance group managers](struct.InstanceGroupManagerSetInstanceTemplateCall.html) (none) -/// * [list instance group managers](struct.InstanceGroupManagerListCall.html) (none) -/// * [insert instance group managers](struct.InstanceGroupManagerInsertCall.html) (request) -/// * [set target pools instance group managers](struct.InstanceGroupManagerSetTargetPoolCall.html) (none) -/// * [recreate instances instance group managers](struct.InstanceGroupManagerRecreateInstanceCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManager { - /// [Output Only] The list of instance actions and the number of instances in this managed instance group that are scheduled for each of those actions. - #[serde(rename="currentActions")] - pub current_actions: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// [Output Only] The URL of the zone where the managed instance group is located (for zonal resources). - pub zone: Option, - /// The name of the managed instance group. The name must be 1-63 characters long, and comply with RFC1035. - pub name: Option, - /// [Output Only] The fingerprint of the resource data. You can use this optional field for optimistic locking when you update the resource. - pub fingerprint: Option, - /// [Output Only] The URL of the Instance Group resource. - #[serde(rename="instanceGroup")] - pub instance_group: Option, - /// The target number of running instances for this managed instance group. Deleting or abandoning instances reduces this number. Resizing the group changes this number. - #[serde(rename="targetSize")] - pub target_size: Option, - /// [Output Only] A unique identifier for this resource type. The server generates this identifier. - pub id: Option, - /// The base instance name to use for instances in this group. The value must be 1-58 characters long. Instances are named by appending a hyphen and a random four-character string to the base instance name. The base instance name must comply with RFC1035. - #[serde(rename="baseInstanceName")] - pub base_instance_name: Option, - /// The URLs for all TargetPool resources to which instances in the instanceGroup field are added. The target pools automatically apply to all of the instances in the managed instance group. - #[serde(rename="targetPools")] - pub target_pools: Option>, - /// The URL of the instance template that is specified for this managed instance group. The group uses this template to create all new instances in the managed instance group. - #[serde(rename="instanceTemplate")] - pub instance_template: Option, - /// [Output Only] The creation timestamp for this managed instance group in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The resource type, which is always compute#instanceGroupManager for managed instance groups. - pub kind: Option, - /// [Output Only] The URL for this managed instance group. The server defines this URL. - #[serde(rename="selfLink")] - pub self_link: Option, - /// Named ports configured for the Instance Groups complementary to this Instance Group Manager. - #[serde(rename="namedPorts")] - pub named_ports: Option>, -} - -impl RequestValue for InstanceGroupManager {} -impl Resource for InstanceGroupManager {} -impl ResponseResult for InstanceGroupManager {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list target vpn gateways](struct.TargetVpnGatewayAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetVpnGatewayAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A map of scoped target vpn gateway lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#targetVpnGateway for target VPN gateways. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for TargetVpnGatewayAggregatedList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get health backend services](struct.BackendServiceGetHealthCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ResourceGroupReference { - /// A URI referencing one of the resource views listed in the backend service. - pub group: Option, -} - -impl RequestValue for ResourceGroupReference {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list managed instances instance group managers](struct.InstanceGroupManagerListManagedInstanceCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagersListManagedInstancesResponse { - /// [Output Only] The list of instances in the managed instance group. - #[serde(rename="managedInstances")] - pub managed_instances: Option>, -} - -impl ResponseResult for InstanceGroupManagersListManagedInstancesResponse {} - - -/// Contains a list of machine types. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list machine types](struct.MachineTypeListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MachineTypeList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of Machine Type resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#machineTypeList for lists of machine types. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for MachineTypeList {} - - -/// Contains a list of SslCertificate resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list ssl certificates](struct.SslCertificateListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SslCertificateList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of SslCertificate resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] Unique identifier for the resource. Defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for SslCertificateList {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DisksScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for DisksScopedListWarningData {} -impl Part for DisksScopedListWarningData {} - - -/// Contains a list of ForwardingRule resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list global forwarding rules](struct.GlobalForwardingRuleListCall.html) (response) -/// * [list forwarding rules](struct.ForwardingRuleListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ForwardingRuleList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of ForwardingRule resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] Unique identifier for the resource. Set by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for ForwardingRuleList {} - - -/// Contains a list of firewalls. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list firewalls](struct.FirewallListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct FirewallList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of Firewall resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#firewallList for lists of firewalls. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for FirewallList {} - - -/// Message for the expected URL mappings. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UrlMapTest { - /// Path portion of the URL. - pub path: Option, - /// Host portion of the URL. - pub host: Option, - /// Description of this test case. - pub description: Option, - /// Expected BackendService resource the given URL should be mapped to. - pub service: Option, -} - -impl Part for UrlMapTest {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list autoscalers](struct.AutoscalerAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AutoscalerAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A map of scoped autoscaler lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#autoscalerAggregatedList for aggregated lists of autoscalers. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for AutoscalerAggregatedList {} - - -/// An Instance resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get serial port output instances](struct.InstanceGetSerialPortOutputCall.html) (none) -/// * [attach disk instances](struct.InstanceAttachDiskCall.html) (none) -/// * [insert instances](struct.InstanceInsertCall.html) (request) -/// * [stop instances](struct.InstanceStopCall.html) (none) -/// * [set scheduling instances](struct.InstanceSetSchedulingCall.html) (none) -/// * [set metadata instances](struct.InstanceSetMetadataCall.html) (none) -/// * [start instances](struct.InstanceStartCall.html) (none) -/// * [detach disk instances](struct.InstanceDetachDiskCall.html) (none) -/// * [delete access config instances](struct.InstanceDeleteAccessConfigCall.html) (none) -/// * [start with encryption key instances](struct.InstanceStartWithEncryptionKeyCall.html) (none) -/// * [get instances](struct.InstanceGetCall.html) (response) -/// * [set tags instances](struct.InstanceSetTagCall.html) (none) -/// * [set machine type instances](struct.InstanceSetMachineTypeCall.html) (none) -/// * [list instances](struct.InstanceListCall.html) (none) -/// * [delete instances](struct.InstanceDeleteCall.html) (none) -/// * [reset instances](struct.InstanceResetCall.html) (none) -/// * [aggregated list instances](struct.InstanceAggregatedListCall.html) (none) -/// * [add access config instances](struct.InstanceAddAccessConfigCall.html) (none) -/// * [set disk auto delete instances](struct.InstanceSetDiskAutoDeleteCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Instance { - /// [Output Only] The CPU platform used by this instance. - #[serde(rename="cpuPlatform")] - pub cpu_platform: Option, - /// [Output Only] The status of the instance. One of the following values: PROVISIONING, STAGING, RUNNING, STOPPING, SUSPENDING, SUSPENDED, and TERMINATED. - pub status: Option, - /// Allows this instance to send and receive packets with non-matching destination or source IPs. This is required if you plan to use this instance to forward routes. For more information, see Enabling IP Forwarding. - #[serde(rename="canIpForward")] - pub can_ip_forward: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// A list of tags to apply to this instance. Tags are used to identify valid sources or targets for network firewalls and are specified by the client during instance creation. The tags can be later modified by the setTags method. Each tag within the list must comply with RFC1035. - pub tags: Option, - /// Scheduling options for this instance. - pub scheduling: Option, - /// Full or partial URL of the machine type resource to use for this instance, in the format: zones/zone/machineTypes/machine-type. This is provided by the client when the instance is created. For example, the following is a valid partial url to a predefined machine type: - /// - /// zones/us-central1-f/machineTypes/n1-standard-1 - /// - /// To create a custom machine type, provide a URL to a machine type in the following format, where CPUS is 1 or an even number up to 32 (2, 4, 6, ... 24, etc), and MEMORY is the total memory for this instance. Memory must be a multiple of 256 MB and must be supplied in MB (e.g. 5 GB of memory is 5120 MB): - /// - /// zones/zone/machineTypes/custom-CPUS-MEMORY - /// - /// For example: zones/us-central1-f/machineTypes/custom-4-5120 - /// - /// For a full list of restrictions, read the Specifications for custom machine types. - #[serde(rename="machineType")] - pub machine_type: Option, - /// A list of service accounts, with their specified scopes, authorized for this instance. Service accounts generate access tokens that can be accessed through the metadata server and used to authenticate applications on the instance. See Service Accounts for more information. - #[serde(rename="serviceAccounts")] - pub service_accounts: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// An array of configurations for this interface. This specifies how this interface is configured to interact with other network services, such as connecting to the internet. Only one interface is supported per instance. - #[serde(rename="networkInterfaces")] - pub network_interfaces: Option>, - /// [Output Only] Type of the resource. Always compute#instance for instances. - pub kind: Option, - /// The name of the resource, provided by the client when initially creating the resource. The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// [Output Only] URL of the zone where the instance resides. - pub zone: Option, - /// Array of disks associated with this instance. Persistent disks must be created before you can assign them. - pub disks: Option>, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// [Output Only] An optional, human-readable explanation of the status. - #[serde(rename="statusMessage")] - pub status_message: Option, - /// The metadata key/value pairs assigned to this instance. This includes custom metadata and predefined keys. - pub metadata: Option, -} - -impl RequestValue for Instance {} -impl Resource for Instance {} -impl ResponseResult for Instance {} - - -/// [Output Only] If warning messages are generated during processing of the operation, this field will be populated. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperationWarnings { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for OperationWarnings {} -impl Part for OperationWarnings {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouterStatusBgpPeerStatus { - /// Status of the BGP peer: {UP, DOWN} - pub status: Option, - /// Time this session has been up. Format: 14 years, 51 weeks, 6 days, 23 hours, 59 minutes, 59 seconds - pub uptime: Option, - /// Name of this BGP peer. Unique within the Routers resource. - pub name: Option, - /// Time this session has been up, in seconds. Format: 145 - #[serde(rename="uptimeSeconds")] - pub uptime_seconds: Option, - /// URL of the VPN tunnel that this BGP peer controls. - #[serde(rename="linkedVpnTunnel")] - pub linked_vpn_tunnel: Option, - /// IP address of the remote BGP interface. - #[serde(rename="peerIpAddress")] - pub peer_ip_address: Option, - /// Routes that were advertised to the remote BGP peer - #[serde(rename="advertisedRoutes")] - pub advertised_routes: Option>, - /// BGP state as specified in RFC1771. - pub state: Option, - /// IP address of the local BGP interface. - #[serde(rename="ipAddress")] - pub ip_address: Option, - /// Number of routes learned from the remote BGP Peer. - #[serde(rename="numLearnedRoutes")] - pub num_learned_routes: Option, -} - -impl Part for RouterStatusBgpPeerStatus {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list instances instance groups](struct.InstanceGroupListInstanceCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupsListInstances { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of instances and any named ports that are assigned to those instances. - pub items: Option>, - /// [Output Only] The resource type, which is always compute#instanceGroupsListInstances for the list of instances in the specified instance group. - pub kind: Option, - /// [Output Only] A unique identifier for this list of instances in the specified instance group. The server generates this identifier. - pub id: Option, - /// [Output Only] The URL for this list of instances in the specified instance groups. The server generates this URL. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for InstanceGroupsListInstances {} - - -/// An Instance Template resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list instance templates](struct.InstanceTemplateListCall.html) (none) -/// * [delete instance templates](struct.InstanceTemplateDeleteCall.html) (none) -/// * [insert instance templates](struct.InstanceTemplateInsertCall.html) (request) -/// * [get instance templates](struct.InstanceTemplateGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceTemplate { - /// [Output Only] The resource type, which is always compute#instanceTemplate for instance templates. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// [Output Only] The creation timestamp for this instance template in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// The instance properties for this instance template. - pub properties: Option, - /// [Output Only] The URL for this instance template. The server defines this URL. - #[serde(rename="selfLink")] - pub self_link: Option, - /// [Output Only] A unique identifier for this instance template. The server defines this identifier. - pub id: Option, -} - -impl RequestValue for InstanceTemplate {} -impl Resource for InstanceTemplate {} -impl ResponseResult for InstanceTemplate {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HealthStatus { - /// URL of the instance resource. - pub instance: Option, - /// Health state of the instance. - #[serde(rename="healthState")] - pub health_state: Option, - /// The IP address represented by this resource. - #[serde(rename="ipAddress")] - pub ip_address: Option, - /// The port on the instance. - pub port: Option, -} - -impl Part for HealthStatus {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ForwardingRulesScopedList { - /// List of forwarding rules contained in this scope. - #[serde(rename="forwardingRules")] - pub forwarding_rules: Option>, - /// Informational warning which replaces the list of forwarding rules when the list is empty. - pub warning: Option, -} - -impl Part for ForwardingRulesScopedList {} - - -/// An Operation resource, used to manage asynchronous API requests. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [resize instance group managers](struct.InstanceGroupManagerResizeCall.html) (response) -/// * [delete ssl certificates](struct.SslCertificateDeleteCall.html) (response) -/// * [patch autoscalers](struct.AutoscalerPatchCall.html) (response) -/// * [delete target https proxies](struct.TargetHttpsProxyDeleteCall.html) (response) -/// * [patch firewalls](struct.FirewallPatchCall.html) (response) -/// * [delete vpn tunnels](struct.VpnTunnelDeleteCall.html) (response) -/// * [set machine type instances](struct.InstanceSetMachineTypeCall.html) (response) -/// * [set target global forwarding rules](struct.GlobalForwardingRuleSetTargetCall.html) (response) -/// * [insert instances](struct.InstanceInsertCall.html) (response) -/// * [delete global forwarding rules](struct.GlobalForwardingRuleDeleteCall.html) (response) -/// * [insert vpn tunnels](struct.VpnTunnelInsertCall.html) (response) -/// * [delete disks](struct.DiskDeleteCall.html) (response) -/// * [add instances instance groups](struct.InstanceGroupAddInstanceCall.html) (response) -/// * [delete target http proxies](struct.TargetHttpProxyDeleteCall.html) (response) -/// * [set scheduling instances](struct.InstanceSetSchedulingCall.html) (response) -/// * [delete instances](struct.InstanceDeleteCall.html) (response) -/// * [add health check target pools](struct.TargetPoolAddHealthCheckCall.html) (response) -/// * [insert instance group managers](struct.InstanceGroupManagerInsertCall.html) (response) -/// * [insert global addresses](struct.GlobalAddresseInsertCall.html) (response) -/// * [set ssl certificates target ssl proxies](struct.TargetSslProxySetSslCertificateCall.html) (response) -/// * [delete https health checks](struct.HttpsHealthCheckDeleteCall.html) (response) -/// * [insert autoscalers](struct.AutoscalerInsertCall.html) (response) -/// * [insert instance groups](struct.InstanceGroupInsertCall.html) (response) -/// * [insert subnetworks](struct.SubnetworkInsertCall.html) (response) -/// * [delete instances instance group managers](struct.InstanceGroupManagerDeleteInstanceCall.html) (response) -/// * [set backend service target ssl proxies](struct.TargetSslProxySetBackendServiceCall.html) (response) -/// * [set instance template instance group managers](struct.InstanceGroupManagerSetInstanceTemplateCall.html) (response) -/// * [resize disks](struct.DiskResizeCall.html) (response) -/// * [insert target pools](struct.TargetPoolInsertCall.html) (response) -/// * [set disk auto delete instances](struct.InstanceSetDiskAutoDeleteCall.html) (response) -/// * [set target pools instance group managers](struct.InstanceGroupManagerSetTargetPoolCall.html) (response) -/// * [insert disks](struct.DiskInsertCall.html) (response) -/// * [delete target ssl proxies](struct.TargetSslProxyDeleteCall.html) (response) -/// * [insert https health checks](struct.HttpsHealthCheckInsertCall.html) (response) -/// * [remove health check target pools](struct.TargetPoolRemoveHealthCheckCall.html) (response) -/// * [set url map target https proxies](struct.TargetHttpsProxySetUrlMapCall.html) (response) -/// * [delete backend services](struct.BackendServiceDeleteCall.html) (response) -/// * [insert url maps](struct.UrlMapInsertCall.html) (response) -/// * [add access config instances](struct.InstanceAddAccessConfigCall.html) (response) -/// * [patch health checks](struct.HealthCheckPatchCall.html) (response) -/// * [insert addresses](struct.AddresseInsertCall.html) (response) -/// * [insert health checks](struct.HealthCheckInsertCall.html) (response) -/// * [insert global forwarding rules](struct.GlobalForwardingRuleInsertCall.html) (response) -/// * [insert target vpn gateways](struct.TargetVpnGatewayInsertCall.html) (response) -/// * [delete addresses](struct.AddresseDeleteCall.html) (response) -/// * [get global operations](struct.GlobalOperationGetCall.html) (response) -/// * [create snapshot disks](struct.DiskCreateSnapshotCall.html) (response) -/// * [update health checks](struct.HealthCheckUpdateCall.html) (response) -/// * [remove instances instance groups](struct.InstanceGroupRemoveInstanceCall.html) (response) -/// * [set metadata instances](struct.InstanceSetMetadataCall.html) (response) -/// * [insert forwarding rules](struct.ForwardingRuleInsertCall.html) (response) -/// * [start instances](struct.InstanceStartCall.html) (response) -/// * [delete instance group managers](struct.InstanceGroupManagerDeleteCall.html) (response) -/// * [insert target instances](struct.TargetInstanceInsertCall.html) (response) -/// * [set target forwarding rules](struct.ForwardingRuleSetTargetCall.html) (response) -/// * [move disk projects](struct.ProjectMoveDiskCall.html) (response) -/// * [insert firewalls](struct.FirewallInsertCall.html) (response) -/// * [set backup target pools](struct.TargetPoolSetBackupCall.html) (response) -/// * [insert routes](struct.RouteInsertCall.html) (response) -/// * [delete instance groups](struct.InstanceGroupDeleteCall.html) (response) -/// * [delete access config instances](struct.InstanceDeleteAccessConfigCall.html) (response) -/// * [set ssl certificates target https proxies](struct.TargetHttpsProxySetSslCertificateCall.html) (response) -/// * [insert networks](struct.NetworkInsertCall.html) (response) -/// * [abandon instances instance group managers](struct.InstanceGroupManagerAbandonInstanceCall.html) (response) -/// * [set tags instances](struct.InstanceSetTagCall.html) (response) -/// * [delete snapshots](struct.SnapshotDeleteCall.html) (response) -/// * [insert target https proxies](struct.TargetHttpsProxyInsertCall.html) (response) -/// * [detach disk instances](struct.InstanceDetachDiskCall.html) (response) -/// * [update backend services](struct.BackendServiceUpdateCall.html) (response) -/// * [recreate instances instance group managers](struct.InstanceGroupManagerRecreateInstanceCall.html) (response) -/// * [attach disk instances](struct.InstanceAttachDiskCall.html) (response) -/// * [set common instance metadata projects](struct.ProjectSetCommonInstanceMetadataCall.html) (response) -/// * [get region operations](struct.RegionOperationGetCall.html) (response) -/// * [patch backend services](struct.BackendServicePatchCall.html) (response) -/// * [set url map target http proxies](struct.TargetHttpProxySetUrlMapCall.html) (response) -/// * [deprecate images](struct.ImageDeprecateCall.html) (response) -/// * [patch http health checks](struct.HttpHealthCheckPatchCall.html) (response) -/// * [insert images](struct.ImageInsertCall.html) (response) -/// * [invalidate cache url maps](struct.UrlMapInvalidateCacheCall.html) (response) -/// * [set named ports instance groups](struct.InstanceGroupSetNamedPortCall.html) (response) -/// * [insert ssl certificates](struct.SslCertificateInsertCall.html) (response) -/// * [move instance projects](struct.ProjectMoveInstanceCall.html) (response) -/// * [delete autoscalers](struct.AutoscalerDeleteCall.html) (response) -/// * [update https health checks](struct.HttpsHealthCheckUpdateCall.html) (response) -/// * [patch url maps](struct.UrlMapPatchCall.html) (response) -/// * [delete subnetworks](struct.SubnetworkDeleteCall.html) (response) -/// * [stop instances](struct.InstanceStopCall.html) (response) -/// * [add instance target pools](struct.TargetPoolAddInstanceCall.html) (response) -/// * [remove instance target pools](struct.TargetPoolRemoveInstanceCall.html) (response) -/// * [delete target pools](struct.TargetPoolDeleteCall.html) (response) -/// * [update firewalls](struct.FirewallUpdateCall.html) (response) -/// * [delete instance templates](struct.InstanceTemplateDeleteCall.html) (response) -/// * [set usage export bucket projects](struct.ProjectSetUsageExportBucketCall.html) (response) -/// * [insert target http proxies](struct.TargetHttpProxyInsertCall.html) (response) -/// * [update url maps](struct.UrlMapUpdateCall.html) (response) -/// * [insert instance templates](struct.InstanceTemplateInsertCall.html) (response) -/// * [delete target instances](struct.TargetInstanceDeleteCall.html) (response) -/// * [delete routers](struct.RouterDeleteCall.html) (response) -/// * [delete target vpn gateways](struct.TargetVpnGatewayDeleteCall.html) (response) -/// * [delete health checks](struct.HealthCheckDeleteCall.html) (response) -/// * [delete global addresses](struct.GlobalAddresseDeleteCall.html) (response) -/// * [patch https health checks](struct.HttpsHealthCheckPatchCall.html) (response) -/// * [delete networks](struct.NetworkDeleteCall.html) (response) -/// * [delete url maps](struct.UrlMapDeleteCall.html) (response) -/// * [insert routers](struct.RouterInsertCall.html) (response) -/// * [reset instances](struct.InstanceResetCall.html) (response) -/// * [update routers](struct.RouterUpdateCall.html) (response) -/// * [patch routers](struct.RouterPatchCall.html) (response) -/// * [insert backend services](struct.BackendServiceInsertCall.html) (response) -/// * [set proxy header target ssl proxies](struct.TargetSslProxySetProxyHeaderCall.html) (response) -/// * [delete http health checks](struct.HttpHealthCheckDeleteCall.html) (response) -/// * [insert http health checks](struct.HttpHealthCheckInsertCall.html) (response) -/// * [delete images](struct.ImageDeleteCall.html) (response) -/// * [update autoscalers](struct.AutoscalerUpdateCall.html) (response) -/// * [insert target ssl proxies](struct.TargetSslProxyInsertCall.html) (response) -/// * [start with encryption key instances](struct.InstanceStartWithEncryptionKeyCall.html) (response) -/// * [delete forwarding rules](struct.ForwardingRuleDeleteCall.html) (response) -/// * [delete firewalls](struct.FirewallDeleteCall.html) (response) -/// * [get zone operations](struct.ZoneOperationGetCall.html) (response) -/// * [update http health checks](struct.HttpHealthCheckUpdateCall.html) (response) -/// * [delete routes](struct.RouteDeleteCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Operation { - /// [Output Only] The status of the operation, which can be one of the following: PENDING, RUNNING, or DONE. - pub status: Option, - /// [Output Only] A textual description of the operation, which is set when the operation is created. - pub description: Option, - /// [Output Only] If warning messages are generated during processing of the operation, this field will be populated. - pub warnings: Option>, - /// [Output Only] If errors are generated during processing of the operation, this field will be populated. - pub error: Option, - /// [Output Only] The unique target ID, which identifies a specific incarnation of the target resource. - #[serde(rename="targetId")] - pub target_id: Option, - /// [Output Only] User who requested the operation, for example: user@example.com. - pub user: Option, - /// [Output Only] The time that this operation was started by the server. This value is in RFC3339 text format. - #[serde(rename="startTime")] - pub start_time: Option, - /// [Output Only] Reserved for future use. - #[serde(rename="clientOperationId")] - pub client_operation_id: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Type of the resource. Always compute#operation for Operation resources. - pub kind: Option, - /// [Output Only] Name of the resource. - pub name: Option, - /// [Output Only] The URL of the zone where the operation resides. Only available when performing per-zone operations. - pub zone: Option, - /// [Output Only] The URL of the region where the operation resides. Only available when performing regional operations. - pub region: Option, - /// [Output Only] The type of operation, such as insert, update, or delete, and so on. - #[serde(rename="operationType")] - pub operation_type: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// [Output Only] The time that this operation was requested. This value is in RFC3339 text format. - #[serde(rename="insertTime")] - pub insert_time: Option, - /// [Output Only] If the operation fails, this field contains the HTTP error message that was returned, such as NOT FOUND. - #[serde(rename="httpErrorMessage")] - pub http_error_message: Option, - /// [Output Only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess when the operation will be complete. This number should monotonically increase as the operation progresses. - pub progress: Option, - /// [Output Only] The time that this operation was completed. This value is in RFC3339 text format. - #[serde(rename="endTime")] - pub end_time: Option, - /// [Output Only] If the operation fails, this field contains the HTTP error status code that was returned. For example, a 404 means the resource was not found. - #[serde(rename="httpErrorStatusCode")] - pub http_error_status_code: Option, - /// [Output Only] An optional textual description of the current status of the operation. - #[serde(rename="statusMessage")] - pub status_message: Option, - /// [Output Only] The URL of the resource that the operation modifies. - #[serde(rename="targetLink")] - pub target_link: Option, -} - -impl ResponseResult for Operation {} - - -/// A Disk resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [insert disks](struct.DiskInsertCall.html) (request) -/// * [delete disks](struct.DiskDeleteCall.html) (none) -/// * [resize disks](struct.DiskResizeCall.html) (none) -/// * [get disks](struct.DiskGetCall.html) (response) -/// * [create snapshot disks](struct.DiskCreateSnapshotCall.html) (none) -/// * [aggregated list disks](struct.DiskAggregatedListCall.html) (none) -/// * [list disks](struct.DiskListCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Disk { - /// [Output Only] The status of disk creation. Applicable statuses includes: CREATING, FAILED, READY, RESTORING. - pub status: Option, - /// The source snapshot used to create this disk. You can provide this as a partial or full URL to the resource. For example, the following are valid values: - /// - https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot - /// - projects/project/global/snapshots/snapshot - /// - global/snapshots/snapshot - #[serde(rename="sourceSnapshot")] - pub source_snapshot: Option, - /// The customer-supplied encryption key of the source image. Required if the source image is protected by a customer-supplied encryption key. - #[serde(rename="sourceImageEncryptionKey")] - pub source_image_encryption_key: Option, - /// [Output Only] Last detach timestamp in RFC3339 text format. - #[serde(rename="lastDetachTimestamp")] - pub last_detach_timestamp: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// [Output Only] The ID value of the image used to create this disk. This value identifies the exact image that was used to create this persistent disk. For example, if you created the persistent disk from an image that was later deleted and recreated under the same name, the source image ID would identify the exact version of the image that was used. - #[serde(rename="sourceImageId")] - pub source_image_id: Option, - /// [Output Only] The unique ID of the snapshot used to create this disk. This value identifies the exact snapshot that was used to create this persistent disk. For example, if you created the persistent disk from a snapshot that was later deleted and recreated under the same name, the source snapshot ID would identify the exact version of the snapshot that was used. - #[serde(rename="sourceSnapshotId")] - pub source_snapshot_id: Option, - /// The source image used to create this disk. If the source image is deleted, this field will not be set. - /// - /// To create a disk with one of the public operating system images, specify the image by its family name. For example, specify family/debian-8 to use the latest Debian 8 image: - /// - /// projects/debian-cloud/global/images/family/debian-8 - /// - /// Alternatively, use a specific version of a public operating system image: - /// - /// projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD - /// - /// To create a disk with a private image that you created, specify the image name in the following format: - /// - /// global/images/my-private-image - /// - /// You can also specify a private image by its image family, which returns the latest version of the image in that family. Replace the image name with family/family-name: - /// - /// global/images/family/my-private-family - #[serde(rename="sourceImage")] - pub source_image: Option, - /// Any applicable publicly visible licenses. - pub licenses: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance - pub users: Option>, - /// Encrypts the disk using a customer-supplied encryption key. - /// - /// After you encrypt a disk with a customer-supplied key, you must provide the same key if you use the disk later (e.g. to create a disk snapshot or an image, or to attach the disk to a virtual machine). - /// - /// Customer-supplied encryption keys do not protect access to metadata of the disk. - /// - /// If you do not provide an encryption key when creating the disk, then the disk will be encrypted using an automatically generated key and you do not need to provide a key to use the disk later. - #[serde(rename="diskEncryptionKey")] - pub disk_encryption_key: Option, - /// Size of the persistent disk, specified in GB. You can specify this field when creating a persistent disk using the sourceImage or sourceSnapshot parameter, or specify it alone to create an empty persistent disk. - /// - /// If you specify this field along with sourceImage or sourceSnapshot, the value of sizeGb must not be less than the size of the sourceImage or the size of the snapshot. - #[serde(rename="sizeGb")] - pub size_gb: Option, - /// [Output Only] Type of the resource. Always compute#disk for disks. - pub kind: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// [Output Only] URL of the zone where the disk resides. - pub zone: Option, - /// [Output Only] Last attach timestamp in RFC3339 text format. - #[serde(rename="lastAttachTimestamp")] - pub last_attach_timestamp: Option, - /// The customer-supplied encryption key of the source snapshot. Required if the source snapshot is protected by a customer-supplied encryption key. - #[serde(rename="sourceSnapshotEncryptionKey")] - pub source_snapshot_encryption_key: Option, - /// URL of the disk type resource describing which disk type to use to create the disk. Provide this when creating the disk. - #[serde(rename="type")] - pub type_: Option, - /// Internal use only. - pub options: Option, - /// [Output Only] Server-defined fully-qualified URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl RequestValue for Disk {} -impl Resource for Disk {} -impl ResponseResult for Disk {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct VpnTunnelsScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for VpnTunnelsScopedListWarningData {} -impl Part for VpnTunnelsScopedListWarningData {} - - -/// A list of TargetHttpProxy resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list target http proxies](struct.TargetHttpProxyListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetHttpProxyList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of TargetHttpProxy resources. - pub items: Option>, - /// Type of resource. Always compute#targetHttpProxyList for lists of target HTTP proxies. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for TargetHttpProxyList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list instances instance groups](struct.InstanceGroupListInstanceCall.html) (none) -/// * [insert instance groups](struct.InstanceGroupInsertCall.html) (request) -/// * [delete instance groups](struct.InstanceGroupDeleteCall.html) (none) -/// * [get instance groups](struct.InstanceGroupGetCall.html) (response) -/// * [add instances instance groups](struct.InstanceGroupAddInstanceCall.html) (none) -/// * [set named ports instance groups](struct.InstanceGroupSetNamedPortCall.html) (none) -/// * [list instance groups](struct.InstanceGroupListCall.html) (none) -/// * [aggregated list instance groups](struct.InstanceGroupAggregatedListCall.html) (none) -/// * [remove instances instance groups](struct.InstanceGroupRemoveInstanceCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroup { - /// [Output Only] The resource type, which is always compute#instanceGroup for instance groups. - pub kind: Option, - /// The URL of the network to which all instances in the instance group belong. - pub network: Option, - /// [Output Only] The URL of the zone where the instance group is located (for zonal resources). - pub zone: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// The name of the instance group. The name must be 1-63 characters long, and comply with RFC1035. - pub name: Option, - /// [Output Only] The fingerprint of the named ports. The system uses this fingerprint to detect conflicts when multiple users change the named ports concurrently. - pub fingerprint: Option, - /// The URL of the subnetwork to which all instances in the instance group belong. - pub subnetwork: Option, - /// Assigns a name to a port number. For example: {name: "http", port: 80} - /// - /// This allows the system to reference ports by the assigned name instead of a port number. Named ports can also contain multiple ports. For example: [{name: "http", port: 80},{name: "http", port: 8080}] - /// - /// Named ports apply to all instances in this instance group. - #[serde(rename="namedPorts")] - pub named_ports: Option>, - /// [Output Only] The creation timestamp for this instance group in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] A unique identifier for this instance group. The server generates this identifier. - pub id: Option, - /// [Output Only] The URL for this instance group. The server generates this URL. - #[serde(rename="selfLink")] - pub self_link: Option, - /// [Output Only] The total number of instances in the instance group. - pub size: Option, -} - -impl RequestValue for InstanceGroup {} -impl Resource for InstanceGroup {} -impl ResponseResult for InstanceGroup {} - - -/// Represents a Network resource. Read Networks and Firewalls for more information. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list networks](struct.NetworkListCall.html) (none) -/// * [delete networks](struct.NetworkDeleteCall.html) (none) -/// * [insert networks](struct.NetworkInsertCall.html) (request) -/// * [get networks](struct.NetworkGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Network { - /// [Output Only] Type of the resource. Always compute#network for networks. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// [Output Only] Server-defined fully-qualified URLs for all subnetworks in this network. - pub subnetworks: Option>, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// The range of internal addresses that are legal on this network. This range is a CIDR specification, for example: 192.168.0.0/16. Provided by the client when the network is created. - #[serde(rename="IPv4Range")] - pub i_pv4_range: Option, - /// A gateway address for default routing to other networks. This value is read only and is selected by the Google Compute Engine, typically as the first usable address in the IPv4Range. - #[serde(rename="gatewayIPv4")] - pub gateway_i_pv4: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// When set to true, the network is created in "auto subnet mode". When set to false, the network is in "custom subnet mode". - /// - /// In "auto subnet mode", a newly created network is assigned the default CIDR of 10.128.0.0/9 and it automatically creates one subnetwork per region. - #[serde(rename="autoCreateSubnetworks")] - pub auto_create_subnetworks: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, -} - -impl RequestValue for Network {} -impl Resource for Network {} -impl ResponseResult for Network {} - - -/// A Zone resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list zones](struct.ZoneListCall.html) (none) -/// * [get zones](struct.ZoneGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Zone { - /// [Output Only] Status of the zone, either UP or DOWN. - pub status: Option, - /// [Output Only] Type of the resource. Always compute#zone for zones. - pub kind: Option, - /// [Output Only] Textual description of the resource. - pub description: Option, - /// [Output Only] The deprecation status associated with this zone. - pub deprecated: Option, - /// [Output Only] Full URL reference to the region which hosts the zone. - pub region: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// [Output Only] Name of the resource. - pub name: Option, -} - -impl Resource for Zone {} -impl ResponseResult for Zone {} - - -/// An access configuration attached to an instance's network interface. Only one access config per instance is supported. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [add access config instances](struct.InstanceAddAccessConfigCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AccessConfig { - /// [Output Only] Type of the resource. Always compute#accessConfig for access configs. - pub kind: Option, - /// The type of configuration. The default and only option is ONE_TO_ONE_NAT. - #[serde(rename="type")] - pub type_: Option, - /// Name of this access configuration. - pub name: Option, - /// An external IP address associated with this instance. Specify an unused static external IP address available to the project or leave this field undefined to use an IP from a shared ephemeral IP address pool. If you specify a static external IP address, it must live in the same region as the zone of the instance. - #[serde(rename="natIP")] - pub nat_ip: Option, -} - -impl RequestValue for AccessConfig {} - - -/// Represents a customer-supplied encryption key -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CustomerEncryptionKey { - /// Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource. - #[serde(rename="rawKey")] - pub raw_key: Option, - /// [Output only] The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource. - pub sha256: Option, -} - -impl Part for CustomerEncryptionKey {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TCPHealthCheck { - /// Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence. - #[serde(rename="portName")] - pub port_name: Option, - /// Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. - #[serde(rename="proxyHeader")] - pub proxy_header: Option, - /// The application data to send once the TCP connection has been established (default value is empty). If both request and response are empty, the connection establishment alone will indicate health. The request data can only be ASCII. - pub request: Option, - /// The TCP port number for the health check request. The default value is 80. - pub port: Option, - /// The bytes to match against the beginning of the response data. If left empty (the default value), any response will indicate health. The response data can only be ASCII. - pub response: Option, -} - -impl Part for TCPHealthCheck {} - - -/// Contains a list of Router resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list routers](struct.RouterListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouterList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of Router resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#router for routers. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for RouterList {} - - -/// The location in Cloud Storage and naming method of the daily usage report. Contains bucket_name and report_name prefix. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set usage export bucket projects](struct.ProjectSetUsageExportBucketCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UsageExportLocation { - /// The name of an existing bucket in Cloud Storage where the usage report object is stored. The Google Service Account is granted write access to this bucket. This can either be the bucket name by itself, such as example-bucket, or the bucket name with gs:// or https://storage.googleapis.com/ in front of it, such as gs://example-bucket. - #[serde(rename="bucketName")] - pub bucket_name: Option, - /// An optional prefix for the name of the usage report object stored in bucketName. If not supplied, defaults to usage. The report is stored as a CSV file named report_name_prefix_gce_YYYYMMDD.csv where YYYYMMDD is the day of the usage according to Pacific Time. If you supply a prefix, it should conform to Cloud Storage object naming conventions. - #[serde(rename="reportNamePrefix")] - pub report_name_prefix: Option, -} - -impl RequestValue for UsageExportLocation {} - - -/// Contains a list of Autoscaler resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list autoscalers](struct.AutoscalerListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AutoscalerList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of Autoscaler resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#autoscalerList for lists of autoscalers. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for AutoscalerList {} - - -/// Contains a list of Subnetwork resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list subnetworks](struct.SubnetworkListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SubnetworkList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// The Subnetwork resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#subnetworkList for lists of subnetworks. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for SubnetworkList {} - - -/// CPU utilization policy. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AutoscalingPolicyCpuUtilization { - /// The target CPU utilization that the autoscaler should maintain. Must be a float value in the range (0, 1]. If not specified, the default is 0.6. - /// - /// If the CPU level is below the target utilization, the autoscaler scales down the number of instances until it reaches the minimum number of instances you specified or until the average CPU of your instances reaches the target utilization. - /// - /// If the average CPU is above the target utilization, the autoscaler scales up until it reaches the maximum number of instances you specified or until the average utilization reaches the target utilization. - #[serde(rename="utilizationTarget")] - pub utilization_target: Option, -} - -impl Part for AutoscalingPolicyCpuUtilization {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [add instances instance groups](struct.InstanceGroupAddInstanceCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupsAddInstancesRequest { - /// The list of instances to add to the instance group. - pub instances: Option>, -} - -impl RequestValue for InstanceGroupsAddInstancesRequest {} - - -/// Represents a Target VPN gateway resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [delete target vpn gateways](struct.TargetVpnGatewayDeleteCall.html) (none) -/// * [aggregated list target vpn gateways](struct.TargetVpnGatewayAggregatedListCall.html) (none) -/// * [get target vpn gateways](struct.TargetVpnGatewayGetCall.html) (response) -/// * [insert target vpn gateways](struct.TargetVpnGatewayInsertCall.html) (request) -/// * [list target vpn gateways](struct.TargetVpnGatewayListCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetVpnGateway { - /// [Output Only] The status of the VPN gateway. - pub status: Option, - /// [Output Only] Type of resource. Always compute#targetVpnGateway for target VPN gateways. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// [Output Only] URL of the region where the target VPN gateway resides. - pub region: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// [Output Only] A list of URLs to the ForwardingRule resources. ForwardingRules are created using compute.forwardingRules.insert and associated to a VPN gateway. - #[serde(rename="forwardingRules")] - pub forwarding_rules: Option>, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] A list of URLs to VpnTunnel resources. VpnTunnels are created using compute.vpntunnels.insert method and associated to a VPN gateway. - pub tunnels: Option>, - /// URL of the network to which this VPN gateway is attached. Provided by the client when the VPN gateway is created. - pub network: Option, -} - -impl RequestValue for TargetVpnGateway {} -impl Resource for TargetVpnGateway {} -impl ResponseResult for TargetVpnGateway {} - - -/// [Output Only] A list of managed instance groups. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list instance group managers](struct.InstanceGroupManagerListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagerList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of managed instance groups. - pub items: Option>, - /// [Output Only] The resource type, which is always compute#instanceGroupManagerList for a list of managed instance groups. - pub kind: Option, - /// [Output Only] A unique identifier for this resource type. The server generates this identifier. - pub id: Option, - /// [Output Only] The URL for this resource type. The server generates this URL. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for InstanceGroupManagerList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list instances](struct.InstanceAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A map of scoped instance lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#instanceAggregatedList for aggregated lists of Instance resources. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for InstanceAggregatedList {} - - -/// [Output Only] Informational warning which replaces the list of operations when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperationsScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for OperationsScopedListWarning {} -impl Part for OperationsScopedListWarning {} - - -/// Message containing connection draining configuration. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ConnectionDraining { - /// Time for which instance will be drained (not accept new connections, but still work to finish started). - #[serde(rename="drainingTimeoutSec")] - pub draining_timeout_sec: Option, -} - -impl Part for ConnectionDraining {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get health backend services](struct.BackendServiceGetHealthCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct BackendServiceGroupHealth { - /// [Output Only] Type of resource. Always compute#backendServiceGroupHealth for the health of backend services. - pub kind: Option, - /// no description provided - #[serde(rename="healthStatus")] - pub health_status: Option>, -} - -impl ResponseResult for BackendServiceGroupHealth {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [move instance projects](struct.ProjectMoveInstanceCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceMoveRequest { - /// The URL of the target instance to move. This can be a full or partial URL. For example, the following are all valid URLs to an instance: - /// - https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances/instance - /// - projects/project/zones/zone/instances/instance - /// - zones/zone/instances/instance - #[serde(rename="targetInstance")] - pub target_instance: Option, - /// The URL of the destination zone to move the instance. This can be a full or partial URL. For example, the following are all valid URLs to a zone: - /// - https://www.googleapis.com/compute/v1/projects/project/zones/zone - /// - projects/project/zones/zone - /// - zones/zone - #[serde(rename="destinationZone")] - pub destination_zone: Option, -} - -impl RequestValue for InstanceMoveRequest {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [move disk projects](struct.ProjectMoveDiskCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DiskMoveRequest { - /// The URL of the target disk to move. This can be a full or partial URL. For example, the following are all valid URLs to a disk: - /// - https://www.googleapis.com/compute/v1/projects/project/zones/zone/disks/disk - /// - projects/project/zones/zone/disks/disk - /// - zones/zone/disks/disk - #[serde(rename="targetDisk")] - pub target_disk: Option, - /// The URL of the destination zone to move the disk. This can be a full or partial URL. For example, the following are all valid URLs to a zone: - /// - https://www.googleapis.com/compute/v1/projects/project/zones/zone - /// - projects/project/zones/zone - /// - zones/zone - #[serde(rename="destinationZone")] - pub destination_zone: Option, -} - -impl RequestValue for DiskMoveRequest {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list instance group managers](struct.InstanceGroupManagerAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagerAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A map of filtered managed instance group lists. - pub items: Option>, - /// [Output Only] The resource type, which is always compute#instanceGroupManagerAggregatedList for an aggregated list of managed instance groups. - pub kind: Option, - /// [Output Only] A unique identifier for this aggregated list of managed instance groups. The server generates this identifier. - pub id: Option, - /// [Output Only] The URL for this resource type. The server generates this URL. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for InstanceGroupManagerAggregatedList {} - - -/// Contains a list of disk types. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list disk types](struct.DiskTypeListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DiskTypeList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of Disk Type resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#diskTypeList for disk types. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for DiskTypeList {} - - -/// Contains a list of instances. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list instances](struct.InstanceListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of instances. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#instanceList for lists of Instance resources. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for InstanceList {} - - -/// An HttpsHealthCheck resource. This resource defines a template for how individual instances should be checked for health, via HTTPS. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get https health checks](struct.HttpsHealthCheckGetCall.html) (response) -/// * [list https health checks](struct.HttpsHealthCheckListCall.html) (none) -/// * [insert https health checks](struct.HttpsHealthCheckInsertCall.html) (request) -/// * [patch https health checks](struct.HttpsHealthCheckPatchCall.html) (request) -/// * [update https health checks](struct.HttpsHealthCheckUpdateCall.html) (request) -/// * [delete https health checks](struct.HttpsHealthCheckDeleteCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HttpsHealthCheck { - /// Type of the resource. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// How long (in seconds) to wait before claiming failure. The default value is 5 seconds. It is invalid for timeoutSec to have a greater value than checkIntervalSec. - #[serde(rename="timeoutSec")] - pub timeout_sec: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// How often (in seconds) to send a health check. The default value is 5 seconds. - #[serde(rename="checkIntervalSec")] - pub check_interval_sec: Option, - /// A so-far healthy instance will be marked unhealthy after this many consecutive failures. The default value is 2. - #[serde(rename="unhealthyThreshold")] - pub unhealthy_threshold: Option, - /// A so-far unhealthy instance will be marked healthy after this many consecutive successes. The default value is 2. - #[serde(rename="healthyThreshold")] - pub healthy_threshold: Option, - /// The value of the host header in the HTTPS health check request. If left empty (default value), the public IP on behalf of which this health check is performed will be used. - pub host: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// The TCP port number for the HTTPS health check request. The default value is 443. - pub port: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// The request path of the HTTPS health check request. The default value is "/". - #[serde(rename="requestPath")] - pub request_path: Option, -} - -impl RequestValue for HttpsHealthCheck {} -impl Resource for HttpsHealthCheck {} -impl ResponseResult for HttpsHealthCheck {} - - -/// An SslCertificate resource. This resource provides a mechanism to upload an SSL key and certificate to the load balancer to serve secure connections from the user. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [delete ssl certificates](struct.SslCertificateDeleteCall.html) (none) -/// * [get ssl certificates](struct.SslCertificateGetCall.html) (response) -/// * [insert ssl certificates](struct.SslCertificateInsertCall.html) (request) -/// * [list ssl certificates](struct.SslCertificateListCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SslCertificate { - /// [Output Only] Type of the resource. Always compute#sslCertificate for SSL certificates. - pub kind: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// A local certificate file. The certificate must be in PEM format. The certificate chain must be no greater than 5 certs long. The chain must include at least one intermediate cert. - pub certificate: Option, - /// A write-only private key in PEM format. Only insert RPCs will include this field. - #[serde(rename="privateKey")] - pub private_key: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, -} - -impl RequestValue for SslCertificate {} -impl Resource for SslCertificate {} -impl ResponseResult for SslCertificate {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set target pools instance group managers](struct.InstanceGroupManagerSetTargetPoolCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagersSetTargetPoolsRequest { - /// The fingerprint of the target pools information. Use this optional property to prevent conflicts when multiple users change the target pools settings concurrently. Obtain the fingerprint with the instanceGroupManagers.get method. Then, include the fingerprint in your request to ensure that you do not overwrite changes that were applied from another concurrent request. - pub fingerprint: Option, - /// The list of target pool URLs that instances in this managed instance group belong to. The managed instance group applies these target pools to all of the instances in the group. Existing instances and new instances in the group all receive these target pool settings. - #[serde(rename="targetPools")] - pub target_pools: Option>, -} - -impl RequestValue for InstanceGroupManagersSetTargetPoolsRequest {} - - -/// [Output Only] Informational warning which replaces the list of autoscalers when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AutoscalersScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for AutoscalersScopedListWarning {} -impl Part for AutoscalersScopedListWarning {} - - -/// The list of ALLOW rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct FirewallAllowed { - /// The IP protocol to which this rule applies. The protocol type is required when creating a firewall rule. This value can either be one of the following well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol number. - #[serde(rename="IPProtocol")] - pub ip_protocol: Option, - /// An optional list of ports to which this rule applies. This field is only applicable for UDP or TCP protocol. Each entry must be either an integer or a range. If not specified, this rule applies to connections through any port. - /// - /// Example inputs include: ["22"], ["80","443"], and ["12345-12349"]. - pub ports: Option>, -} - -impl NestedType for FirewallAllowed {} -impl Part for FirewallAllowed {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [add health check target pools](struct.TargetPoolAddHealthCheckCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPoolsAddHealthCheckRequest { - /// A list of HttpHealthCheck resources to add to the target pool. - #[serde(rename="healthChecks")] - pub health_checks: Option>, -} - -impl RequestValue for TargetPoolsAddHealthCheckRequest {} - - -/// Contains a list of networks. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list networks](struct.NetworkListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct NetworkList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of Network resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#networkList for lists of networks. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource . - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for NetworkList {} - - -/// Contains a list of zone resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list zones](struct.ZoneListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ZoneList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of Zone resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for ZoneList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set ssl certificates target https proxies](struct.TargetHttpsProxySetSslCertificateCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetHttpsProxiesSetSslCertificatesRequest { - /// New set of SslCertificate resources to associate with this TargetHttpsProxy resource. Currently exactly one SslCertificate resource must be specified. - #[serde(rename="sslCertificates")] - pub ssl_certificates: Option>, -} - -impl RequestValue for TargetHttpsProxiesSetSslCertificatesRequest {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get health target pools](struct.TargetPoolGetHealthCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceReference { - /// The URL for a specific instance. - pub instance: Option, -} - -impl RequestValue for InstanceReference {} - - -/// A list of instance templates. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list instance templates](struct.InstanceTemplateListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceTemplateList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] list of InstanceTemplate resources. - pub items: Option>, - /// [Output Only] The resource type, which is always compute#instanceTemplatesListResponse for instance template lists. - pub kind: Option, - /// [Output Only] A unique identifier for this instance template. The server defines this identifier. - pub id: Option, - /// [Output Only] The URL for this instance template list. The server defines this URL. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for InstanceTemplateList {} - - -/// Contains a list of TargetInstance resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list target instances](struct.TargetInstanceListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetInstanceList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of TargetInstance resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for TargetInstanceList {} - - -/// Contains a list of HttpHealthCheck resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list http health checks](struct.HttpHealthCheckListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HttpHealthCheckList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of HttpHealthCheck resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] Unique identifier for the resource. Defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for HttpHealthCheckList {} - - -/// An instance-attached disk resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [attach disk instances](struct.InstanceAttachDiskCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AttachedDisk { - /// Encrypts or decrypts a disk using a customer-supplied encryption key. - /// - /// If you are creating a new disk, this field encrypts the new disk using an encryption key that you provide. If you are attaching an existing disk that is already encrypted, this field decrypts the disk using the customer-supplied encryption key. - /// - /// If you encrypt a disk using a customer-supplied key, you must provide the same key again when you attempt to use this resource at a later time. For example, you must provide the key when you create a snapshot or an image from the disk or when you attach the disk to a virtual machine instance. - /// - /// If you do not provide an encryption key, then the disk will be encrypted using an automatically generated key and you do not need to provide a key to use the disk later. - /// - /// Instance templates do not store customer-supplied encryption keys, so you cannot use your own keys to encrypt disks in a managed instance group. - #[serde(rename="diskEncryptionKey")] - pub disk_encryption_key: Option, - /// Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance. - /// - /// If not specified, the server chooses a default device name to apply to this disk, in the form persistent-disks-x, where x is a number assigned by Google Compute Engine. This field is only applicable for persistent disks. - #[serde(rename="deviceName")] - pub device_name: Option, - /// [Output Only] Type of the resource. Always compute#attachedDisk for attached disks. - pub kind: Option, - /// [Input Only] Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new instance. - /// - /// This property is mutually exclusive with the source property; you can only define one or the other, but not both. - #[serde(rename="initializeParams")] - pub initialize_params: Option, - /// Specifies whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance). - #[serde(rename="autoDelete")] - pub auto_delete: Option, - /// Assigns a zero-based index to this disk, where 0 is reserved for the boot disk. For example, if you have many disks attached to an instance, each disk would have a unique index number. If not specified, the server will choose an appropriate value. - pub index: Option, - /// Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem. - pub boot: Option, - /// Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI. Persistent disks must always use SCSI and the request will fail if you attempt to attach a persistent disk in any other format than SCSI. Local SSDs can use either NVME or SCSI. For performance characteristics of SCSI over NVMe, see Local SSD performance. - pub interface: Option, - /// The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode. - pub mode: Option, - /// [Output Only] Any valid publicly visible licenses. - pub licenses: Option>, - /// Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, the default is PERSISTENT. - #[serde(rename="type")] - pub type_: Option, - /// Specifies a valid partial or full URL to an existing Persistent Disk resource. This field is only applicable for persistent disks. Note that for InstanceTemplate, it is just disk name, not URL for the disk. - pub source: Option, -} - -impl RequestValue for AttachedDisk {} - - -/// An HealthCheck resource. This resource defines a template for how individual virtual machines should be checked for health, via one of the supported protocols. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [insert health checks](struct.HealthCheckInsertCall.html) (request) -/// * [patch health checks](struct.HealthCheckPatchCall.html) (request) -/// * [get health checks](struct.HealthCheckGetCall.html) (response) -/// * [update health checks](struct.HealthCheckUpdateCall.html) (request) -/// * [list health checks](struct.HealthCheckListCall.html) (none) -/// * [delete health checks](struct.HealthCheckDeleteCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HealthCheck { - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// How long (in seconds) to wait before claiming failure. The default value is 5 seconds. It is invalid for timeoutSec to have greater value than checkIntervalSec. - #[serde(rename="timeoutSec")] - pub timeout_sec: Option, - /// no description provided - #[serde(rename="httpHealthCheck")] - pub http_health_check: Option, - /// A so-far healthy instance will be marked unhealthy after this many consecutive failures. The default value is 2. - #[serde(rename="unhealthyThreshold")] - pub unhealthy_threshold: Option, - /// no description provided - #[serde(rename="http2HealthCheck")] - pub http2_health_check: Option, - /// no description provided - #[serde(rename="httpsHealthCheck")] - pub https_health_check: Option, - /// [Output Only] Creation timestamp in 3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// Type of the resource. - pub kind: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// How often (in seconds) to send a health check. The default value is 5 seconds. - #[serde(rename="checkIntervalSec")] - pub check_interval_sec: Option, - /// no description provided - #[serde(rename="tcpHealthCheck")] - pub tcp_health_check: Option, - /// A so-far unhealthy instance will be marked healthy after this many consecutive successes. The default value is 2. - #[serde(rename="healthyThreshold")] - pub healthy_threshold: Option, - /// Specifies the type of the healthCheck, either TCP, UDP, SSL, HTTP, HTTPS or HTTP2. If not specified, the default is TCP. Exactly one of the protocol-specific health check field must be specified, which must match type field. - #[serde(rename="type")] - pub type_: Option, - /// no description provided - #[serde(rename="sslHealthCheck")] - pub ssl_health_check: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl RequestValue for HealthCheck {} -impl Resource for HealthCheck {} -impl ResponseResult for HealthCheck {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ManagedInstance { - /// [Output Only] The current action that the managed instance group has scheduled for the instance. Possible values: - /// - NONE The instance is running, and the managed instance group does not have any scheduled actions for this instance. - /// - CREATING The managed instance group is creating this instance. If the group fails to create this instance, it will try again until it is successful. - /// - CREATING_WITHOUT_RETRIES The managed instance group is attempting to create this instance only once. If the group fails to create this instance, it does not try again and the group's targetSize value is decreased instead. - /// - RECREATING The managed instance group is recreating this instance. - /// - DELETING The managed instance group is permanently deleting this instance. - /// - ABANDONING The managed instance group is abandoning this instance. The instance will be removed from the instance group and from any target pools that are associated with this group. - /// - RESTARTING The managed instance group is restarting the instance. - /// - REFRESHING The managed instance group is applying configuration changes to the instance without stopping it. For example, the group can update the target pool list for an instance without stopping that instance. - #[serde(rename="currentAction")] - pub current_action: Option, - /// [Output Only] The URL of the instance. The URL can exist even if the instance has not yet been created. - pub instance: Option, - /// [Output Only] Information about the last attempt to create or delete the instance. - #[serde(rename="lastAttempt")] - pub last_attempt: Option, - /// [Output only] The unique identifier for this resource. This field is empty when instance does not exist. - pub id: Option, - /// [Output Only] The status of the instance. This field is empty when the instance does not exist. - #[serde(rename="instanceStatus")] - pub instance_status: Option, -} - -impl Part for ManagedInstance {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list forwarding rules](struct.ForwardingRuleAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ForwardingRuleAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A map of scoped forwarding rule lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#forwardingRuleAggregatedList for lists of forwarding rules. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for ForwardingRuleAggregatedList {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TestFailure { - /// no description provided - pub path: Option, - /// no description provided - #[serde(rename="actualService")] - pub actual_service: Option, - /// no description provided - pub host: Option, - /// no description provided - #[serde(rename="expectedService")] - pub expected_service: Option, -} - -impl Part for TestFailure {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list target pools](struct.TargetPoolAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPoolAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A map of scoped target pool lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#targetPoolAggregatedList for aggregated lists of target pools. - pub kind: Option, - /// [Output Only] Unique identifier for the resource. Defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for TargetPoolAggregatedList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set proxy header target ssl proxies](struct.TargetSslProxySetProxyHeaderCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetSslProxiesSetProxyHeaderRequest { - /// The new type of proxy header to append before sending data to the backend. NONE or PROXY_V1 are allowed. - #[serde(rename="proxyHeader")] - pub proxy_header: Option, -} - -impl RequestValue for TargetSslProxiesSetProxyHeaderRequest {} - - -/// A Subnetwork resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [insert subnetworks](struct.SubnetworkInsertCall.html) (request) -/// * [get subnetworks](struct.SubnetworkGetCall.html) (response) -/// * [list subnetworks](struct.SubnetworkListCall.html) (none) -/// * [aggregated list subnetworks](struct.SubnetworkAggregatedListCall.html) (none) -/// * [delete subnetworks](struct.SubnetworkDeleteCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Subnetwork { - /// [Output Only] Type of the resource. Always compute#subnetwork for Subnetwork resources. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// [Output Only] The gateway address for default routes to reach destination addresses outside this subnetwork. - #[serde(rename="gatewayAddress")] - pub gateway_address: Option, - /// URL of the region where the Subnetwork resides. - pub region: Option, - /// The name of the resource, provided by the client when initially creating the resource. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// The range of internal addresses that are owned by this subnetwork. Provide this property when you create the subnetwork. For example, 10.0.0.0/8 or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network. - #[serde(rename="ipCidrRange")] - pub ip_cidr_range: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// The URL of the network to which this subnetwork belongs, provided by the client when initially creating the subnetwork. Only networks that are in the distributed mode can have subnetworks. - pub network: Option, -} - -impl RequestValue for Subnetwork {} -impl Resource for Subnetwork {} -impl ResponseResult for Subnetwork {} - - -/// Contains a list of Route resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list routes](struct.RouteListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouteList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of Route resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] Unique identifier for the resource. Defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for RouteList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [invalidate cache url maps](struct.UrlMapInvalidateCacheCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CacheInvalidationRule { - /// no description provided - pub path: Option, -} - -impl RequestValue for CacheInvalidationRule {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [delete instances instance group managers](struct.InstanceGroupManagerDeleteInstanceCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagersDeleteInstancesRequest { - /// The list of instances to delete from this managed instance group. Specify one or more instance URLs. - pub instances: Option>, -} - -impl RequestValue for InstanceGroupManagersDeleteInstancesRequest {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [preview routers](struct.RouterPreviewCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RoutersPreviewResponse { - /// Preview of given router. - pub resource: Option, -} - -impl ResponseResult for RoutersPreviewResponse {} - - -/// An Image resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [delete images](struct.ImageDeleteCall.html) (none) -/// * [insert images](struct.ImageInsertCall.html) (request) -/// * [get images](struct.ImageGetCall.html) (response) -/// * [get from family images](struct.ImageGetFromFamilyCall.html) (response) -/// * [deprecate images](struct.ImageDeprecateCall.html) (none) -/// * [list images](struct.ImageListCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Image { - /// [Output Only] The status of the image. An image can be used to create other resources, such as instances, only after the image has been successfully created and the status is set to READY. Possible values are FAILED, PENDING, or READY. - pub status: Option, - /// The customer-supplied encryption key of the source disk. Required if the source disk is protected by a customer-supplied encryption key. - #[serde(rename="sourceDiskEncryptionKey")] - pub source_disk_encryption_key: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// The name of the image family to which this image belongs. You can create disks by specifying an image family instead of a specific image name. The image family always returns its latest image that is not deprecated. The name of the image family must comply with RFC1035. - pub family: Option, - /// Size of the image tar.gz archive stored in Google Cloud Storage (in bytes). - #[serde(rename="archiveSizeBytes")] - pub archive_size_bytes: Option, - /// The ID value of the disk used to create this image. This value may be used to determine whether the image was taken from the current or a previous instance of a given disk name. - #[serde(rename="sourceDiskId")] - pub source_disk_id: Option, - /// Any applicable license URI. - pub licenses: Option>, - /// The type of the image used to create this disk. The default and only value is RAW - #[serde(rename="sourceType")] - pub source_type: Option, - /// Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// [Output Only] Type of the resource. Always compute#image for images. - pub kind: Option, - /// The parameters of the raw disk image. - #[serde(rename="rawDisk")] - pub raw_disk: Option, - /// URL of the The source disk used to create this image. This can be a full or valid partial URL. You must provide either this property or the rawDisk.source property but not both to create an image. For example, the following are valid values: - /// - https://www.googleapis.com/compute/v1/projects/project/zones/zone/disk/disk - /// - projects/project/zones/zone/disk/disk - /// - zones/zone/disks/disk - #[serde(rename="sourceDisk")] - pub source_disk: Option, - /// The deprecation status associated with this image. - pub deprecated: Option, - /// Size of the image when restored onto a persistent disk (in GB). - #[serde(rename="diskSizeGb")] - pub disk_size_gb: Option, - /// Encrypts the image using a customer-supplied encryption key. - /// - /// After you encrypt an image with a customer-supplied key, you must provide the same key if you use the image later (e.g. to create a disk from the image). - /// - /// Customer-supplied encryption keys do not protect access to metadata of the disk. - /// - /// If you do not provide an encryption key when creating the image, then the disk will be encrypted using an automatically generated key and you do not need to provide a key to use the image later. - #[serde(rename="imageEncryptionKey")] - pub image_encryption_key: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl RequestValue for Image {} -impl Resource for Image {} -impl ResponseResult for Image {} - - -/// A list of Disk resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list disks](struct.DiskListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DiskList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of persistent disks. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#diskList for lists of disks. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for DiskList {} - - -/// The parameters of the raw disk image. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ImageRawDisk { - /// The format used to encode and transmit the block device, which should be TAR. This is just a container and transmission format and not a runtime format. Provided by the client when the disk image is created. - #[serde(rename="containerType")] - pub container_type: Option, - /// The full Google Cloud Storage URL where the disk image is stored. You must provide either this property or the sourceDisk property but not both. - pub source: Option, - /// An optional SHA1 checksum of the disk image before unpackaging; provided by the client when the disk image is created. - #[serde(rename="sha1Checksum")] - pub sha1_checksum: Option, -} - -impl NestedType for ImageRawDisk {} -impl Part for ImageRawDisk {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RoutersScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for RoutersScopedListWarningData {} -impl Part for RoutersScopedListWarningData {} - - -/// Cloud Autoscaler policy. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AutoscalingPolicy { - /// Configuration parameters of autoscaling based on a custom metric. - #[serde(rename="customMetricUtilizations")] - pub custom_metric_utilizations: Option>, - /// The maximum number of instances that the autoscaler can scale up to. This is required when creating or updating an autoscaler. The maximum number of replicas should not be lower than minimal number of replicas. - #[serde(rename="maxNumReplicas")] - pub max_num_replicas: Option, - /// Defines the CPU utilization policy that allows the autoscaler to scale based on the average CPU utilization of a managed instance group. - #[serde(rename="cpuUtilization")] - pub cpu_utilization: Option, - /// The minimum number of replicas that the autoscaler can scale down to. This cannot be less than 0. If not provided, autoscaler will choose a default value depending on maximum number of instances allowed. - #[serde(rename="minNumReplicas")] - pub min_num_replicas: Option, - /// The number of seconds that the autoscaler should wait before it starts collecting information from a new instance. This prevents the autoscaler from collecting information when the instance is initializing, during which the collected usage would not be reliable. The default time autoscaler waits is 60 seconds. - /// - /// Virtual machine initialization times might vary because of numerous factors. We recommend that you test how long an instance may take to initialize. To do this, create an instance and time the startup process. - #[serde(rename="coolDownPeriodSec")] - pub cool_down_period_sec: Option, - /// Configuration parameters of autoscaling based on load balancer. - #[serde(rename="loadBalancingUtilization")] - pub load_balancing_utilization: Option, -} - -impl Part for AutoscalingPolicy {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperationsScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for OperationsScopedListWarningData {} -impl Part for OperationsScopedListWarningData {} - - -/// Contains a list of BackendService resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list backend services](struct.BackendServiceListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct BackendServiceList { - /// [Output Only] A token used to continue a truncated list request. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of BackendService resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#backendServiceList for lists of backend services. - pub kind: Option, - /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for BackendServiceList {} - - -/// A TargetHttpsProxy resource. This resource defines an HTTPS proxy. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get target https proxies](struct.TargetHttpsProxyGetCall.html) (response) -/// * [insert target https proxies](struct.TargetHttpsProxyInsertCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetHttpsProxy { - /// [Output Only] Type of resource. Always compute#targetHttpsProxy for target HTTPS proxies. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// URLs to SslCertificate resources that are used to authenticate connections between users and the load balancer. Currently, exactly one SSL certificate must be specified. - #[serde(rename="sslCertificates")] - pub ssl_certificates: Option>, - /// A fully-qualified or valid partial URL to the UrlMap resource that defines the mapping from URL to the BackendService. For example, the following are all valid URLs for specifying a URL map: - /// - https://www.googleapis.compute/v1/projects/project/global/urlMaps/url-map - /// - projects/project/global/urlMaps/url-map - /// - global/urlMaps/url-map - #[serde(rename="urlMap")] - pub url_map: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, -} - -impl RequestValue for TargetHttpsProxy {} -impl ResponseResult for TargetHttpsProxy {} - - -/// Configuration parameters of autoscaling based on load balancing. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AutoscalingPolicyLoadBalancingUtilization { - /// Fraction of backend capacity utilization (set in HTTP(s) load balancing configuration) that autoscaler should maintain. Must be a positive float value. If not defined, the default is 0.8. - #[serde(rename="utilizationTarget")] - pub utilization_target: Option, -} - -impl Part for AutoscalingPolicyLoadBalancingUtilization {} - - -/// Contains a list of region resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list regions](struct.RegionListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RegionList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of Region resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#regionList for lists of regions. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for RegionList {} - - -/// Message containing information of one individual backend. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Backend { - /// The fully-qualified URL of a zonal Instance Group resource. This instance group defines the list of instances that serve traffic. Member virtual machine instances from each instance group must live in the same zone as the instance group itself. No two backends in a backend service are allowed to use same Instance Group resource. - /// - /// Note that you must specify an Instance Group resource using the fully-qualified URL, rather than a partial URL. - /// - /// When the BackendService has load balancing scheme INTERNAL, the instance group must be in a zone within the same region as the BackendService. - pub group: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization target for the group. The default is 0.8. Valid range is [0.0, 1.0]. - /// - /// This cannot be used for internal load balancing. - #[serde(rename="maxUtilization")] - pub max_utilization: Option, - /// The max requests per second (RPS) that a single backend instance can handle.This is used to calculate the capacity of the group. Can be used in either balancing mode. For RATE mode, either maxRate or maxRatePerInstance must be set. - /// - /// This cannot be used for internal load balancing. - #[serde(rename="maxRatePerInstance")] - pub max_rate_per_instance: Option, - /// The max number of simultaneous connections that a single backend instance can handle. This is used to calculate the capacity of the group. Can be used in either CONNECTION or UTILIZATION balancing modes. For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must be set. - /// - /// This cannot be used for internal load balancing. - #[serde(rename="maxConnectionsPerInstance")] - pub max_connections_per_instance: Option, - /// A multiplier applied to the group's maximum servicing capacity (based on UTILIZATION, RATE or CONNECTION). Default value is 1, which means the group will serve up to 100% of its configured capacity (depending on balancingMode). A setting of 0 means the group is completely drained, offering 0% of its available Capacity. Valid range is [0.0,1.0]. - /// - /// This cannot be used for internal load balancing. - #[serde(rename="capacityScaler")] - pub capacity_scaler: Option, - /// The max requests per second (RPS) of the group. Can be used with either RATE or UTILIZATION balancing modes, but required if RATE mode. For RATE mode, either maxRate or maxRatePerInstance must be set. - /// - /// This cannot be used for internal load balancing. - #[serde(rename="maxRate")] - pub max_rate: Option, - /// The max number of simultaneous connections for the group. Can be used with either CONNECTION or UTILIZATION balancing modes. For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must be set. - /// - /// This cannot be used for internal load balancing. - #[serde(rename="maxConnections")] - pub max_connections: Option, - /// Specifies the balancing mode for this backend. For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION. Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). - /// - /// This cannot be used for internal load balancing. - #[serde(rename="balancingMode")] - pub balancing_mode: Option, -} - -impl Part for Backend {} - - -/// An instance's serial console output. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get serial port output instances](struct.InstanceGetSerialPortOutputCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SerialPortOutput { - /// [Output Only] Type of the resource. Always compute#serialPortOutput for serial port output. - pub kind: Option, - /// [Output Only] The contents of the console output. - pub contents: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for SerialPortOutput {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperationsScopedList { - /// [Output Only] List of operations contained in this scope. - pub operations: Option>, - /// [Output Only] Informational warning which replaces the list of operations when the list is empty. - pub warning: Option, -} - -impl Part for OperationsScopedList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [start with encryption key instances](struct.InstanceStartWithEncryptionKeyCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstancesStartWithEncryptionKeyRequest { - /// Array of disks associated with this instance that are protected with a customer-supplied encryption key. - /// - /// In order to start the instance, the disk url and its corresponding key must be provided. - /// - /// If the disk is not protected with a customer-supplied encryption key it should not be specified. - pub disks: Option>, -} - -impl RequestValue for InstancesStartWithEncryptionKeyRequest {} - - -/// [Output Only] Informational warning which replaces the list of instances when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstancesScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for InstancesScopedListWarning {} -impl Part for InstancesScopedListWarning {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouterStatus { - /// no description provided - #[serde(rename="bgpPeerStatus")] - pub bgp_peer_status: Option>, - /// URI of the network to which this router belongs. - pub network: Option, - /// Best routes for this router's network. - #[serde(rename="bestRoutes")] - pub best_routes: Option>, -} - -impl Part for RouterStatus {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouterBgp { - /// Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN, either 16-bit or 32-bit. The value will be fixed for this router resource. All VPN tunnels that link to this router will have the same local ASN. - pub asn: Option, -} - -impl Part for RouterBgp {} - - -/// [Output Only] List of extended scratch disks assigned to the instance. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MachineTypeScratchDisks { - /// Size of the scratch disk, defined in GB. - #[serde(rename="diskGb")] - pub disk_gb: Option, -} - -impl NestedType for MachineTypeScratchDisks {} -impl Part for MachineTypeScratchDisks {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [add instance target pools](struct.TargetPoolAddInstanceCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPoolsAddInstanceRequest { - /// A full or partial URL to an instance to add to this target pool. This can be a full or partial URL. For example, the following are valid URLs: - /// - https://www.googleapis.com/compute/v1/projects/project-id/zones/zone/instances/instance-name - /// - projects/project-id/zones/zone/instances/instance-name - /// - zones/zone/instances/instance-name - pub instances: Option>, -} - -impl RequestValue for TargetPoolsAddInstanceRequest {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AddressesScopedList { - /// [Output Only] Informational warning which replaces the list of addresses when the list is empty. - pub warning: Option, - /// [Output Only] List of addresses contained in this scope. - pub addresses: Option>, -} - -impl Part for AddressesScopedList {} - - -/// Contains a list of TargetVpnGateway resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list target vpn gateways](struct.TargetVpnGatewayListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetVpnGatewayList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of TargetVpnGateway resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#targetVpnGateway for target VPN gateways. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for TargetVpnGatewayList {} - - -/// [Output Only] Informational warning which replaces the list of disk types when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DiskTypesScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for DiskTypesScopedListWarning {} -impl Part for DiskTypesScopedListWarning {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list instance groups](struct.InstanceGroupAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A map of scoped instance group lists. - pub items: Option>, - /// [Output Only] The resource type, which is always compute#instanceGroupAggregatedList for aggregated lists of instance groups. - pub kind: Option, - /// [Output Only] A unique identifier for this aggregated list of instance groups. The server generates this identifier. - pub id: Option, - /// [Output Only] The URL for this resource type. The server generates this URL. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for InstanceGroupAggregatedList {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouterInterface { - /// URI of linked VPN tunnel. It must be in the same region as the router. Each interface can have at most one linked resource. - #[serde(rename="linkedVpnTunnel")] - pub linked_vpn_tunnel: Option, - /// IP address and range of the interface. The IP range must be in the RFC3927 link-local IP space. The value must be a CIDR-formatted string, for example: 169.254.0.1/30. NOTE: Do not truncate the address as it represents the IP address of the interface. - #[serde(rename="ipRange")] - pub ip_range: Option, - /// Name of this interface entry. The name must be 1-63 characters long and comply with RFC1035. - pub name: Option, -} - -impl Part for RouterInterface {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [validate url maps](struct.UrlMapValidateCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UrlMapsValidateRequest { - /// Content of the UrlMap to be validated. - pub resource: Option, -} - -impl RequestValue for UrlMapsValidateRequest {} - - -/// Informational warning which replaces the list of routers when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RoutersScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for RoutersScopedListWarning {} -impl Part for RoutersScopedListWarning {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AutoscalersScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for AutoscalersScopedListWarningData {} -impl Part for AutoscalersScopedListWarningData {} - - -/// Custom utilization metric policy. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AutoscalingPolicyCustomMetricUtilization { - /// The identifier of the Cloud Monitoring metric. The metric cannot have negative values and should be a utilization metric, which means that the number of virtual machines handling requests should increase or decrease proportionally to the metric. The metric must also have a label of compute.googleapis.com/resource_id with the value of the instance's unique ID, although this alone does not guarantee that the metric is valid. - /// - /// For example, the following is a valid metric: - /// compute.googleapis.com/instance/network/received_bytes_count - /// - /// - /// The following is not a valid metric because it does not increase or decrease based on usage: - /// compute.googleapis.com/instance/cpu/reserved_cores - pub metric: Option, - /// Defines how target utilization value is expressed for a Cloud Monitoring metric. Either GAUGE, DELTA_PER_SECOND, or DELTA_PER_MINUTE. If not specified, the default is GAUGE. - #[serde(rename="utilizationTargetType")] - pub utilization_target_type: Option, - /// Target value of the metric which autoscaler should maintain. Must be a positive value. - #[serde(rename="utilizationTarget")] - pub utilization_target: Option, -} - -impl Part for AutoscalingPolicyCustomMetricUtilization {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list disks](struct.DiskAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DiskAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A map of scoped disk lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#diskAggregatedList for aggregated lists of persistent disks. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for DiskAggregatedList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list global operations](struct.GlobalOperationAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperationAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A map of scoped operation lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#operationAggregatedList for aggregated lists of operations. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for OperationAggregatedList {} - - -/// Contains a list of routers. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list routers](struct.RouterAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouterAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A map of scoped router lists. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for RouterAggregatedList {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstancesScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for InstancesScopedListWarningData {} -impl Part for InstancesScopedListWarningData {} - - -/// Contains a list of TargetSslProxy resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list target ssl proxies](struct.TargetSslProxyListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetSslProxyList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of TargetSslProxy resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for TargetSslProxyList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list addresses](struct.AddresseAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AddressAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A map of scoped address lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#addressAggregatedList for aggregated lists of addresses. - pub kind: Option, - /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for AddressAggregatedList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list instances instance groups](struct.InstanceGroupListInstanceCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupsListInstancesRequest { - /// A filter for the state of the instances in the instance group. Valid options are ALL or RUNNING. If you do not specify this parameter the list includes all instances regardless of their state. - #[serde(rename="instanceState")] - pub instance_state: Option, -} - -impl RequestValue for InstanceGroupsListInstancesRequest {} - - -/// A set of instance tags. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set tags instances](struct.InstanceSetTagCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Tags { - /// An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035. - pub items: Option>, - /// Specifies a fingerprint for this request, which is essentially a hash of the metadata's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update metadata. You must always provide an up-to-date fingerprint hash in order to update or change metadata. - /// - /// To see the latest fingerprint, make get() request to the instance. - pub fingerprint: Option, -} - -impl RequestValue for Tags {} - - -/// Informational warning which replaces the list of addresses when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPoolsScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for TargetPoolsScopedListWarning {} -impl Part for TargetPoolsScopedListWarning {} - - -/// Contains a list of Snapshot resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list snapshots](struct.SnapshotListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SnapshotList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of Snapshot resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for SnapshotList {} - - -/// A service account. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ServiceAccount { - /// The list of scopes to be made available for this service account. - pub scopes: Option>, - /// Email address of the service account. - pub email: Option, -} - -impl Part for ServiceAccount {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SubnetworksScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for SubnetworksScopedListWarningData {} -impl Part for SubnetworksScopedListWarningData {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [remove instance target pools](struct.TargetPoolRemoveInstanceCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPoolsRemoveInstanceRequest { - /// URLs of the instances to be removed from target pool. - pub instances: Option>, -} - -impl RequestValue for TargetPoolsRemoveInstanceRequest {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MachineTypesScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for MachineTypesScopedListWarningData {} -impl Part for MachineTypesScopedListWarningData {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HTTP2HealthCheck { - /// Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence. - #[serde(rename="portName")] - pub port_name: Option, - /// The value of the host header in the HTTP/2 health check request. If left empty (default value), the IP on behalf of which this health check is performed will be used. - pub host: Option, - /// Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. - #[serde(rename="proxyHeader")] - pub proxy_header: Option, - /// The TCP port number for the health check request. The default value is 443. - pub port: Option, - /// The request path of the HTTP/2 health check request. The default value is /. - #[serde(rename="requestPath")] - pub request_path: Option, -} - -impl Part for HTTP2HealthCheck {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DiskTypesScopedList { - /// [Output Only] Informational warning which replaces the list of disk types when the list is empty. - pub warning: Option, - /// [Output Only] List of disk types contained in this scope. - #[serde(rename="diskTypes")] - pub disk_types: Option>, -} - -impl Part for DiskTypesScopedList {} - - -/// A BackendService resource. This resource defines a group of backend virtual machines and their serving capacity. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get backend services](struct.BackendServiceGetCall.html) (response) -/// * [insert backend services](struct.BackendServiceInsertCall.html) (request) -/// * [list backend services](struct.BackendServiceListCall.html) (none) -/// * [update backend services](struct.BackendServiceUpdateCall.html) (request) -/// * [get health backend services](struct.BackendServiceGetHealthCall.html) (none) -/// * [delete backend services](struct.BackendServiceDeleteCall.html) (none) -/// * [patch backend services](struct.BackendServicePatchCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct BackendService { - /// no description provided - #[serde(rename="connectionDraining")] - pub connection_draining: Option, - /// The protocol this BackendService uses to communicate with backends. - /// - /// Possible values are HTTP, HTTPS, HTTP2, TCP and SSL. The default is HTTP. - /// - /// For internal load balancing, the possible values are TCP and UDP, and the default is TCP. - pub protocol: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// How many seconds to wait for the backend before considering it a failed request. Default is 30 seconds. - #[serde(rename="timeoutSec")] - pub timeout_sec: Option, - /// Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a BackendService. An up-to-date fingerprint must be provided in order to update the BackendService. - pub fingerprint: Option, - /// Name of backend port. The same name should appear in the instance groups referenced by this service. Required when the load balancing scheme is EXTERNAL. - /// - /// When the load balancing scheme is INTERNAL, this field is not used. - #[serde(rename="portName")] - pub port_name: Option, - /// The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health checking this BackendService. Currently at most one health check can be specified, and a health check is required. - /// - /// For internal load balancing, a URL to a HealthCheck resource must be specified instead. - #[serde(rename="healthChecks")] - pub health_checks: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Type of resource. Always compute#backendService for backend services. - pub kind: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// If true, enable Cloud CDN for this BackendService. - /// - /// When the load balancing scheme is INTERNAL, this field is not used. - #[serde(rename="enableCDN")] - pub enable_cdn: Option, - /// [Output Only] URL of the region where the regional backend service resides. This field is not applicable to global backend services. - pub region: Option, - /// Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set to 0, the cookie is non-persistent and lasts only until the end of the browser session (or equivalent). The maximum allowed value for TTL is one day. - /// - /// When the load balancing scheme is INTERNAL, this field is not used. - #[serde(rename="affinityCookieTtlSec")] - pub affinity_cookie_ttl_sec: Option, - /// Type of session affinity to use. The default is NONE. - /// - /// When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE. - /// - /// When the load balancing scheme is INTERNAL, can be NONE, CLIENT_IP, CLIENT_IP_PROTO, or CLIENT_IP_PORT_PROTO. - /// - /// When the protocol is UDP, this field is not used. - #[serde(rename="sessionAffinity")] - pub session_affinity: Option, - /// Deprecated in favor of portName. The TCP port to connect on the backend. The default value is 80. - /// - /// This cannot be used for internal load balancing. - pub port: Option, - /// The list of backends that serve this BackendService. - pub backends: Option>, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl RequestValue for BackendService {} -impl Resource for BackendService {} -impl ResponseResult for BackendService {} - - -/// Router resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get routers](struct.RouterGetCall.html) (response) -/// * [list routers](struct.RouterListCall.html) (none) -/// * [patch routers](struct.RouterPatchCall.html) (request) -/// * [aggregated list routers](struct.RouterAggregatedListCall.html) (none) -/// * [insert routers](struct.RouterInsertCall.html) (request) -/// * [delete routers](struct.RouterDeleteCall.html) (none) -/// * [update routers](struct.RouterUpdateCall.html) (request) -/// * [get router status routers](struct.RouterGetRouterStatuCall.html) (none) -/// * [preview routers](struct.RouterPreviewCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Router { - /// [Output Only] Type of resource. Always compute#router for routers. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// Router interfaces. Each interface requires either one linked resource (e.g. linkedVpnTunnel) or IP address and IP address range (e.g. ipRange). - pub interfaces: Option>, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// BGP information specific to this router. - pub bgp: Option, - /// BGP information that needs to be configured into the routing stack to establish the BGP peering. It must specify peer ASN and either interface name, IP, or peer IP. Please refer to RFC4273. - #[serde(rename="bgpPeers")] - pub bgp_peers: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] URI of the region where the router resides. - pub region: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// URI of the network to which this router belongs. - pub network: Option, -} - -impl RequestValue for Router {} -impl Resource for Router {} -impl ResponseResult for Router {} - - -/// Contains a list of images. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list images](struct.ImageListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ImageList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of Image resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for ImageList {} - - -/// An informational warning that appears when the list of addresses is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SubnetworksScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for SubnetworksScopedListWarning {} -impl Part for SubnetworksScopedListWarning {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetVpnGatewaysScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for TargetVpnGatewaysScopedListWarningData {} -impl Part for TargetVpnGatewaysScopedListWarningData {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperationWarningsData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for OperationWarningsData {} -impl Part for OperationWarningsData {} - - -/// Informational warning which replaces the list of forwarding rules when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ForwardingRulesScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for ForwardingRulesScopedListWarning {} -impl Part for ForwardingRulesScopedListWarning {} - - -/// UrlMaps A host-matching rule for a URL. If matched, will use the named PathMatcher to select the BackendService. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HostRule { - /// The list of host patterns to match. They must be valid hostnames, except * will match any string of ([a-z0-9-.]*). In that case, * must be the first character and must be followed in the pattern by either - or .. - pub hosts: Option>, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// The name of the PathMatcher to use to match the path portion of the URL if the hostRule matches the URL's host portion. - #[serde(rename="pathMatcher")] - pub path_matcher: Option, -} - -impl Part for HostRule {} - - -/// Represents a Firewall resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [patch firewalls](struct.FirewallPatchCall.html) (request) -/// * [list firewalls](struct.FirewallListCall.html) (none) -/// * [get firewalls](struct.FirewallGetCall.html) (response) -/// * [update firewalls](struct.FirewallUpdateCall.html) (request) -/// * [delete firewalls](struct.FirewallDeleteCall.html) (none) -/// * [insert firewalls](struct.FirewallInsertCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Firewall { - /// [Output Ony] Type of the resource. Always compute#firewall for firewall rules. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// If source tags are specified, the firewall will apply only to traffic with source IP that belongs to a tag listed in source tags. Source tags cannot be used to control traffic to an instance's external IP address. Because tags are associated with an instance, not an IP address. One or both of sourceRanges and sourceTags may be set. If both properties are set, the firewall will apply to traffic that has source IP address within sourceRanges OR the source IP that belongs to a tag listed in the sourceTags property. The connection does not need to match both properties for the firewall to apply. - #[serde(rename="sourceTags")] - pub source_tags: Option>, - /// If source ranges are specified, the firewall will apply only to traffic that has source IP address in these ranges. These ranges must be expressed in CIDR format. One or both of sourceRanges and sourceTags may be set. If both properties are set, the firewall will apply to traffic that has source IP address within sourceRanges OR the source IP that belongs to a tag listed in the sourceTags property. The connection does not need to match both properties for the firewall to apply. - #[serde(rename="sourceRanges")] - pub source_ranges: Option>, - /// Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// A list of instance tags indicating sets of instances located in the network that may make network connections as specified in allowed[]. If no targetTags are specified, the firewall rule applies to all instances on the specified network. - #[serde(rename="targetTags")] - pub target_tags: Option>, - /// The list of ALLOW rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection. - pub allowed: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// URL of the network resource for this firewall rule. If not specified when creating a firewall rule, the default network is used: - /// global/networks/default - /// If you choose to specify this property, you can specify the network as a full or partial URL. For example, the following are all valid URLs: - /// - https://www.googleapis.com/compute/v1/projects/myproject/global/networks/my-network - /// - projects/myproject/global/networks/my-network - /// - global/networks/default - pub network: Option, -} - -impl RequestValue for Firewall {} -impl Resource for Firewall {} -impl ResponseResult for Firewall {} - - -/// Contains a list of Operation resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list region operations](struct.RegionOperationListCall.html) (response) -/// * [list zone operations](struct.ZoneOperationListCall.html) (response) -/// * [list global operations](struct.GlobalOperationListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperationList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of Operation resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#operations for Operations resource. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for OperationList {} - - -/// The named port. For example: . -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct NamedPort { - /// The name for this named port. The name must be 1-63 characters long, and comply with RFC1035. - pub name: Option, - /// The port number, which can be a value between 1 and 65535. - pub port: Option, -} - -impl Part for NamedPort {} - - -/// A TargetInstance resource. This resource defines an endpoint instance that terminates traffic of certain protocols. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [delete target instances](struct.TargetInstanceDeleteCall.html) (none) -/// * [aggregated list target instances](struct.TargetInstanceAggregatedListCall.html) (none) -/// * [get target instances](struct.TargetInstanceGetCall.html) (response) -/// * [list target instances](struct.TargetInstanceListCall.html) (none) -/// * [insert target instances](struct.TargetInstanceInsertCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetInstance { - /// NAT option controlling how IPs are NAT'ed to the instance. Currently only NO_NAT (default value) is supported. - #[serde(rename="natPolicy")] - pub nat_policy: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// [Output Only] URL of the zone where the target instance resides. - pub zone: Option, - /// [Output Only] The type of the resource. Always compute#targetInstance for target instances. - pub kind: Option, - /// A URL to the virtual machine instance that handles traffic for this target instance. When creating a target instance, you can provide the fully-qualified URL or a valid partial URL to the desired virtual machine. For example, the following are all valid URLs: - /// - https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances/instance - /// - projects/project/zones/zone/instances/instance - /// - zones/zone/instances/instance - pub instance: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, -} - -impl RequestValue for TargetInstance {} -impl Resource for TargetInstance {} -impl ResponseResult for TargetInstance {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list target instances](struct.TargetInstanceAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetInstanceAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A map of scoped target instance lists. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for TargetInstanceAggregatedList {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HTTPSHealthCheck { - /// Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence. - #[serde(rename="portName")] - pub port_name: Option, - /// The value of the host header in the HTTPS health check request. If left empty (default value), the IP on behalf of which this health check is performed will be used. - pub host: Option, - /// Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. - #[serde(rename="proxyHeader")] - pub proxy_header: Option, - /// The TCP port number for the health check request. The default value is 443. - pub port: Option, - /// The request path of the HTTPS health check request. The default value is /. - #[serde(rename="requestPath")] - pub request_path: Option, -} - -impl Part for HTTPSHealthCheck {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupsScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for InstanceGroupsScopedListWarningData {} -impl Part for InstanceGroupsScopedListWarningData {} - - -/// Informational warning which replaces the list of addresses when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct VpnTunnelsScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for VpnTunnelsScopedListWarning {} -impl Part for VpnTunnelsScopedListWarning {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list disk types](struct.DiskTypeAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DiskTypeAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A map of scoped disk type lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#diskTypeAggregatedList. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for DiskTypeAggregatedList {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstancesScopedList { - /// [Output Only] List of instances contained in this scope. - pub instances: Option>, - /// [Output Only] Informational warning which replaces the list of instances when the list is empty. - pub warning: Option, -} - -impl Part for InstancesScopedList {} - - -/// [Output Only] Encountered errors during the last attempt to create or delete the instance. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ManagedInstanceLastAttemptErrors { - /// [Output Only] The array of errors encountered while processing this operation. - pub errors: Option>, -} - -impl NestedType for ManagedInstanceLastAttemptErrors {} -impl Part for ManagedInstanceLastAttemptErrors {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list machine types](struct.MachineTypeAggregatedListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MachineTypeAggregatedList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A map of scoped machine type lists. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#machineTypeAggregatedList for aggregated lists of machine types. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for MachineTypeAggregatedList {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CustomerEncryptionKeyProtectedDisk { - /// Decrypts data associated with the disk with a customer-supplied encryption key. - #[serde(rename="diskEncryptionKey")] - pub disk_encryption_key: Option, - /// Specifies a valid partial or full URL to an existing Persistent Disk resource. This field is only applicable for persistent disks. - pub source: Option, -} - -impl Part for CustomerEncryptionKeyProtectedDisk {} - - -/// Informational warning which replaces the list of addresses when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetInstancesScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for TargetInstancesScopedListWarning {} -impl Part for TargetInstancesScopedListWarning {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [abandon instances instance group managers](struct.InstanceGroupManagerAbandonInstanceCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagersAbandonInstancesRequest { - /// The URL for one or more instances to abandon from the managed instance group. - pub instances: Option>, -} - -impl RequestValue for InstanceGroupManagersAbandonInstancesRequest {} - - -/// A list of InstanceGroup resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list instance groups](struct.InstanceGroupListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of instance groups. - pub items: Option>, - /// [Output Only] The resource type, which is always compute#instanceGroupList for instance group lists. - pub kind: Option, - /// [Output Only] A unique identifier for this list of instance groups. The server generates this identifier. - pub id: Option, - /// [Output Only] The URL for this resource type. The server generates this URL. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for InstanceGroupList {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AddressesScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for AddressesScopedListWarningData {} -impl Part for AddressesScopedListWarningData {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [delete vpn tunnels](struct.VpnTunnelDeleteCall.html) (none) -/// * [aggregated list vpn tunnels](struct.VpnTunnelAggregatedListCall.html) (none) -/// * [get vpn tunnels](struct.VpnTunnelGetCall.html) (response) -/// * [insert vpn tunnels](struct.VpnTunnelInsertCall.html) (request) -/// * [list vpn tunnels](struct.VpnTunnelListCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct VpnTunnel { - /// [Output Only] Detailed status message for the VPN tunnel. - #[serde(rename="detailedStatus")] - pub detailed_status: Option, - /// IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway. Acceptable IKE versions are 1 or 2. Default version is 2. - #[serde(rename="ikeVersion")] - pub ike_version: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// Local traffic selector to use when establishing the VPN tunnel with peer VPN gateway. The value should be a CIDR formatted string, for example: 192.168.0.0/16. The ranges should be disjoint. - #[serde(rename="localTrafficSelector")] - pub local_traffic_selector: Option>, - /// Hash of the shared secret. - #[serde(rename="sharedSecretHash")] - pub shared_secret_hash: Option, - /// URL of router resource to be used for dynamic routing. - pub router: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// Shared secret used to set the secure session between the Cloud VPN gateway and the peer VPN gateway. - #[serde(rename="sharedSecret")] - pub shared_secret: Option, - /// IP address of the peer VPN gateway. - #[serde(rename="peerIp")] - pub peer_ip: Option, - /// [Output Only] Type of resource. Always compute#vpnTunnel for VPN tunnels. - pub kind: Option, - /// Remote traffic selectors to use when establishing the VPN tunnel with peer VPN gateway. The value should be a CIDR formatted string, for example: 192.168.0.0/16. The ranges should be disjoint. - #[serde(rename="remoteTrafficSelector")] - pub remote_traffic_selector: Option>, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// [Output Only] URL of the region where the VPN tunnel resides. - pub region: Option, - /// [Output Only] The status of the VPN tunnel. - pub status: Option, - /// URL of the VPN gateway with which this VPN tunnel is associated. Provided by the client when the VPN tunnel is created. - #[serde(rename="targetVpnGateway")] - pub target_vpn_gateway: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl RequestValue for VpnTunnel {} -impl Resource for VpnTunnel {} -impl ResponseResult for VpnTunnel {} - - -/// Deprecation status for a public resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [deprecate images](struct.ImageDeprecateCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DeprecationStatus { - /// An optional RFC3339 timestamp on or after which the deprecation state of this resource will be changed to DELETED. - pub deleted: Option, - /// An optional RFC3339 timestamp on or after which the deprecation state of this resource will be changed to DEPRECATED. - pub deprecated: Option, - /// The deprecation state of this resource. This can be DEPRECATED, OBSOLETE, or DELETED. Operations which create a new resource using a DEPRECATED resource will return successfully, but with a warning indicating the deprecated resource and recommending its replacement. Operations which use OBSOLETE or DELETED resources will be rejected and result in an error. - pub state: Option, - /// An optional RFC3339 timestamp on or after which the deprecation state of this resource will be changed to OBSOLETE. - pub obsolete: Option, - /// The URL of the suggested replacement for a deprecated resource. The suggested replacement resource must be the same kind of resource as the deprecated resource. - pub replacement: Option, -} - -impl RequestValue for DeprecationStatus {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouterBgpPeer { - /// Name of the interface the BGP peer is associated with. - #[serde(rename="interfaceName")] - pub interface_name: Option, - /// IP address of the interface inside Google Cloud Platform. - #[serde(rename="ipAddress")] - pub ip_address: Option, - /// The priority of routes advertised to this BGP peer. In the case where there is more than one matching route of maximum length, the routes with lowest priority value win. - #[serde(rename="advertisedRoutePriority")] - pub advertised_route_priority: Option, - /// IP address of the BGP interface outside Google cloud. - #[serde(rename="peerIpAddress")] - pub peer_ip_address: Option, - /// Peer BGP Autonomous System Number (ASN). For VPN use case, this value can be different for every tunnel. - #[serde(rename="peerAsn")] - pub peer_asn: Option, - /// Name of this BGP peer. The name must be 1-63 characters long and comply with RFC1035. - pub name: Option, -} - -impl Part for RouterBgpPeer {} - - -/// [Output Only] Informational warning which replaces the list of disks when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DisksScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for DisksScopedListWarning {} -impl Part for DisksScopedListWarning {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set machine type instances](struct.InstanceSetMachineTypeCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstancesSetMachineTypeRequest { - /// Full or partial URL of the machine type resource. See Machine Types for a full list of machine types. For example: zones/us-central1-f/machineTypes/n1-standard-1 - #[serde(rename="machineType")] - pub machine_type: Option, -} - -impl RequestValue for InstancesSetMachineTypeRequest {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set url map target https proxies](struct.TargetHttpsProxySetUrlMapCall.html) (request) -/// * [set url map target http proxies](struct.TargetHttpProxySetUrlMapCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UrlMapReference { - /// no description provided - #[serde(rename="urlMap")] - pub url_map: Option, -} - -impl RequestValue for UrlMapReference {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SSLHealthCheck { - /// Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence. - #[serde(rename="portName")] - pub port_name: Option, - /// Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. - #[serde(rename="proxyHeader")] - pub proxy_header: Option, - /// The application data to send once the SSL connection has been established (default value is empty). If both request and response are empty, the connection establishment alone will indicate health. The request data can only be ASCII. - pub request: Option, - /// The TCP port number for the health check request. The default value is 443. - pub port: Option, - /// The bytes to match against the beginning of the response data. If left empty (the default value), any response will indicate health. The response data can only be ASCII. - pub response: Option, -} - -impl Part for SSLHealthCheck {} - - -/// [Output Only] The array of errors encountered while processing this operation. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperationErrorErrors { - /// [Output Only] An optional, human-readable error message. - pub message: Option, - /// [Output Only] The error type identifier for this error. - pub code: Option, - /// [Output Only] Indicates the field in the request that caused the error. This property is optional. - pub location: Option, -} - -impl NestedType for OperationErrorErrors {} -impl Part for OperationErrorErrors {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SubnetworksScopedList { - /// List of subnetworks contained in this scope. - pub subnetworks: Option>, - /// An informational warning that appears when the list of addresses is empty. - pub warning: Option, -} - -impl Part for SubnetworksScopedList {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagersScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for InstanceGroupManagersScopedListWarningData {} -impl Part for InstanceGroupManagersScopedListWarningData {} - - -/// A full or valid partial URL to a health check. For example, the following are valid URLs: -/// - https://www.googleapis.com/compute/beta/projects/project-id/global/httpHealthChecks/health-check -/// - projects/project-id/global/httpHealthChecks/health-check -/// - global/httpHealthChecks/health-check -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HealthCheckReference { - /// no description provided - #[serde(rename="healthCheck")] - pub health_check: Option, -} - -impl Part for HealthCheckReference {} - - -/// [Output Only] An informational warning that replaces the list of instance groups when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupsScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for InstanceGroupsScopedListWarning {} -impl Part for InstanceGroupsScopedListWarning {} - - -/// Represents an Autoscaler resource. Autoscalers allow you to automatically scale virtual machine instances in managed instance groups according to an autoscaling policy that you define. For more information, read Autoscaling Groups of Instances. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [insert autoscalers](struct.AutoscalerInsertCall.html) (request) -/// * [update autoscalers](struct.AutoscalerUpdateCall.html) (request) -/// * [get autoscalers](struct.AutoscalerGetCall.html) (response) -/// * [list autoscalers](struct.AutoscalerListCall.html) (none) -/// * [patch autoscalers](struct.AutoscalerPatchCall.html) (request) -/// * [aggregated list autoscalers](struct.AutoscalerAggregatedListCall.html) (none) -/// * [delete autoscalers](struct.AutoscalerDeleteCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Autoscaler { - /// [Output Only] Type of the resource. Always compute#autoscaler for autoscalers. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// [Output Only] URL of the zone where the instance group resides (for autoscalers living in zonal scope). - pub zone: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// The configuration parameters for the autoscaling algorithm. You can define one or more of the policies for an autoscaler: cpuUtilization, customMetricUtilizations, and loadBalancingUtilization. - /// - /// If none of these are specified, the default will be to autoscale based on cpuUtilization to 0.6 or 60%. - #[serde(rename="autoscalingPolicy")] - pub autoscaling_policy: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// URL of the managed instance group that this autoscaler will scale. - pub target: Option, -} - -impl RequestValue for Autoscaler {} -impl Resource for Autoscaler {} -impl ResponseResult for Autoscaler {} - - -/// [Output Only] Informational warning which replaces the list of addresses when the list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetVpnGatewaysScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for TargetVpnGatewaysScopedListWarning {} -impl Part for TargetVpnGatewaysScopedListWarning {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [remove instances instance groups](struct.InstanceGroupRemoveInstanceCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupsRemoveInstancesRequest { - /// The list of instances to remove from the instance group. - pub instances: Option>, -} - -impl RequestValue for InstanceGroupsRemoveInstancesRequest {} - - -/// [Input Only] Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new instance. -/// -/// This property is mutually exclusive with the source property; you can only define one or the other, but not both. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AttachedDiskInitializeParams { - /// Specifies the size of the disk in base-2 GB. - #[serde(rename="diskSizeGb")] - pub disk_size_gb: Option, - /// The customer-supplied encryption key of the source image. Required if the source image is protected by a customer-supplied encryption key. - /// - /// Instance templates do not store customer-supplied encryption keys, so you cannot create disks for instances in a managed instance group if the source images are encrypted with your own keys. - #[serde(rename="sourceImageEncryptionKey")] - pub source_image_encryption_key: Option, - /// The source image used to create this disk. If the source image is deleted, this field will not be set. - /// - /// To create a disk with one of the public operating system images, specify the image by its family name. For example, specify family/debian-8 to use the latest Debian 8 image: - /// - /// projects/debian-cloud/global/images/family/debian-8 - /// - /// Alternatively, use a specific version of a public operating system image: - /// - /// projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD - /// - /// To create a disk with a private image that you created, specify the image name in the following format: - /// - /// global/images/my-private-image - /// - /// You can also specify a private image by its image family, which returns the latest version of the image in that family. Replace the image name with family/family-name: - /// - /// global/images/family/my-private-family - #[serde(rename="sourceImage")] - pub source_image: Option, - /// Specifies the disk name. If not specified, the default is to use the name of the instance. - #[serde(rename="diskName")] - pub disk_name: Option, - /// Specifies the disk type to use to create the instance. If not specified, the default is pd-standard, specified using the full URL. For example: - /// - /// https://www.googleapis.com/compute/v1/projects/project/zones/zone/diskTypes/pd-standard - /// - /// Other values include pd-ssd and local-ssd. If you define this field, you can provide either the full or partial URL. For example, the following are valid values: - /// - https://www.googleapis.com/compute/v1/projects/project/zones/zone/diskTypes/diskType - /// - projects/project/zones/zone/diskTypes/diskType - /// - zones/zone/diskTypes/diskType Note that for InstanceTemplate, this is the name of the disk type, not URL. - #[serde(rename="diskType")] - pub disk_type: Option, -} - -impl Part for AttachedDiskInitializeParams {} - - -/// A quotas entry. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Quota { - /// [Output Only] Current usage of this metric. - pub usage: Option, - /// [Output Only] Name of the quota metric. - pub metric: Option, - /// [Output Only] Quota limit for this metric. - pub limit: Option, -} - -impl Part for Quota {} - - -/// A TargetPool resource. This resource defines a pool of instances, associated HttpHealthCheck resources, and the fallback target pool. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get health target pools](struct.TargetPoolGetHealthCall.html) (none) -/// * [add instance target pools](struct.TargetPoolAddInstanceCall.html) (none) -/// * [remove instance target pools](struct.TargetPoolRemoveInstanceCall.html) (none) -/// * [remove health check target pools](struct.TargetPoolRemoveHealthCheckCall.html) (none) -/// * [delete target pools](struct.TargetPoolDeleteCall.html) (none) -/// * [insert target pools](struct.TargetPoolInsertCall.html) (request) -/// * [aggregated list target pools](struct.TargetPoolAggregatedListCall.html) (none) -/// * [list target pools](struct.TargetPoolListCall.html) (none) -/// * [add health check target pools](struct.TargetPoolAddHealthCheckCall.html) (none) -/// * [get target pools](struct.TargetPoolGetCall.html) (response) -/// * [set backup target pools](struct.TargetPoolSetBackupCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPool { - /// This field is applicable only when the containing target pool is serving a forwarding rule as the primary pool (i.e., not as a backup pool to some other target pool). The value of the field must be in [0, 1]. - /// - /// If set, backupPool must also be set. They together define the fallback behavior of the primary target pool: if the ratio of the healthy instances in the primary pool is at or below this number, traffic arriving at the load-balanced IP will be directed to the backup pool. - /// - /// In case where failoverRatio is not set or all the instances in the backup pool are unhealthy, the traffic will be directed back to the primary pool in the "force" mode, where traffic will be spread to the healthy instances with the best effort, or to all instances when no instance is healthy. - #[serde(rename="failoverRatio")] - pub failover_ratio: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// [Output Only] URL of the region where the target pool resides. - pub region: Option, - /// [Output Only] Type of the resource. Always compute#targetPool for target pools. - pub kind: Option, - /// Sesssion affinity option, must be one of the following values: - /// NONE: Connections from the same client IP may go to any instance in the pool. - /// CLIENT_IP: Connections from the same client IP will go to the same instance in the pool while that instance remains healthy. - /// CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol will go to the same instance in the pool while that instance remains healthy. - #[serde(rename="sessionAffinity")] - pub session_affinity: Option, - /// A list of resource URLs to the virtual machine instances serving this pool. They must live in zones contained in the same region as this pool. - pub instances: Option>, - /// This field is applicable only when the containing target pool is serving a forwarding rule as the primary pool, and its failoverRatio field is properly set to a value between [0, 1]. - /// - /// backupPool and failoverRatio together define the fallback behavior of the primary target pool: if the ratio of the healthy instances in the primary pool is at or below failoverRatio, traffic arriving at the load-balanced IP will be directed to the backup pool. - /// - /// In case where failoverRatio and backupPool are not set, or all the instances in the backup pool are unhealthy, the traffic will be directed back to the primary pool in the "force" mode, where traffic will be spread to the healthy instances with the best effort, or to all instances when no instance is healthy. - #[serde(rename="backupPool")] - pub backup_pool: Option, - /// A list of URLs to the HttpHealthCheck resource. A member instance in this pool is considered healthy if and only if all specified health checks pass. An empty list means all member instances will be considered healthy at all times. - #[serde(rename="healthChecks")] - pub health_checks: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, -} - -impl RequestValue for TargetPool {} -impl Resource for TargetPool {} -impl ResponseResult for TargetPool {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPoolsScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for TargetPoolsScopedListWarningData {} -impl Part for TargetPoolsScopedListWarningData {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetInstancesScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for TargetInstancesScopedListWarningData {} -impl Part for TargetInstancesScopedListWarningData {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get router status routers](struct.RouterGetRouterStatuCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouterStatusResponse { - /// Type of resource. - pub kind: Option, - /// no description provided - pub result: Option, -} - -impl ResponseResult for RouterStatusResponse {} - - -/// A reserved address resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [insert global addresses](struct.GlobalAddresseInsertCall.html) (request) -/// * [insert addresses](struct.AddresseInsertCall.html) (request) -/// * [get addresses](struct.AddresseGetCall.html) (response) -/// * [get global addresses](struct.GlobalAddresseGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Address { - /// [Output Only] The status of the address, which can be either IN_USE or RESERVED. An address that is RESERVED is currently reserved and available to use. An IN_USE address is currently being used by another resource and is not available. - pub status: Option, - /// [Output Only] Type of the resource. Always compute#address for addresses. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// [Output Only] URL of the region where the regional address resides. This field is not applicable to global addresses. - pub region: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// The static external IP address represented by this resource. - pub address: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// [Output Only] The URLs of the resources that are using this address. - pub users: Option>, -} - -impl RequestValue for Address {} -impl ResponseResult for Address {} - - -/// [Output Only] An informational warning that appears when the machine types list is empty. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MachineTypesScopedListWarning { - /// [Output Only] A human-readable description of the warning code. - pub message: Option, - /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. - pub code: Option, - /// [Output Only] Metadata about this warning in key: value format. For example: - /// "data": [ { "key": "scope", "value": "zones/us-east1-d" } - pub data: Option>, -} - -impl NestedType for MachineTypesScopedListWarning {} -impl Part for MachineTypesScopedListWarning {} - - -/// A ForwardingRule resource. A ForwardingRule resource specifies which pool of target virtual machines to forward a packet to if it matches the given [IPAddress, IPProtocol, portRange] tuple. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [aggregated list forwarding rules](struct.ForwardingRuleAggregatedListCall.html) (none) -/// * [get global forwarding rules](struct.GlobalForwardingRuleGetCall.html) (response) -/// * [insert global forwarding rules](struct.GlobalForwardingRuleInsertCall.html) (request) -/// * [insert forwarding rules](struct.ForwardingRuleInsertCall.html) (request) -/// * [delete forwarding rules](struct.ForwardingRuleDeleteCall.html) (none) -/// * [set target forwarding rules](struct.ForwardingRuleSetTargetCall.html) (none) -/// * [get forwarding rules](struct.ForwardingRuleGetCall.html) (response) -/// * [list forwarding rules](struct.ForwardingRuleListCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ForwardingRule { - /// [Output Only] Type of the resource. Always compute#forwardingRule for Forwarding Rule resources. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to ports in the specified range will be forwarded to target. Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port ranges. - /// - /// This field is not used for internal load balancing. - #[serde(rename="portRange")] - pub port_range: Option, - /// [Output Only] URL of the region where the regional forwarding rule resides. This field is not applicable to global forwarding rules. - pub region: Option, - /// Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH, SCTP or ICMP. - /// - /// When the load balancing scheme is INTERNAL, - /// The IP address that this forwarding rule is serving on behalf of. - /// - /// For global forwarding rules, the address must be a global IP; for regional forwarding rules, the address must live in the same region as the forwarding rule. By default, this field is empty and an ephemeral IP from the same scope (global or regional) will be assigned. - /// - /// When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address belonging to the network/subnetwork configured for the forwarding rule. A reserved address cannot be used. If the field is empty, the IP address will be automatically allocated from the internal IP range of the subnetwork or network configured for this forwarding rule. - #[serde(rename="IPAddress")] - pub ip_address: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// The URL of the target resource to receive the matched traffic. For regional forwarding rules, this target must live in the same region as the forwarding rule. For global forwarding rules, this target must be a global TargetHttpProxy or TargetHttpsProxy resource. The forwarded traffic must be of a type appropriate to the target object. For example, TargetHttpProxy requires HTTP traffic, and TargetHttpsProxy requires HTTPS traffic. - /// - /// This field is not used for internal load balancing. - pub target: Option, -} - -impl RequestValue for ForwardingRule {} -impl Resource for ForwardingRule {} -impl ResponseResult for ForwardingRule {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DiskTypesScopedListWarningData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for DiskTypesScopedListWarningData {} -impl Part for DiskTypesScopedListWarningData {} - - -/// A license resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get licenses](struct.LicenseGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct License { - /// [Output Only] If true, the customer will be charged license fee for running software that contains this license on an instance. - #[serde(rename="chargesUseFee")] - pub charges_use_fee: Option, - /// [Output Only] Type of resource. Always compute#license for licenses. - pub kind: Option, - /// [Output Only] Name of the resource. The name is 1-63 characters long and complies with RFC1035. - pub name: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl Resource for License {} -impl ResponseResult for License {} - - -/// An HttpHealthCheck resource. This resource defines a template for how individual instances should be checked for health, via HTTP. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [insert http health checks](struct.HttpHealthCheckInsertCall.html) (request) -/// * [update http health checks](struct.HttpHealthCheckUpdateCall.html) (request) -/// * [get http health checks](struct.HttpHealthCheckGetCall.html) (response) -/// * [patch http health checks](struct.HttpHealthCheckPatchCall.html) (request) -/// * [list http health checks](struct.HttpHealthCheckListCall.html) (none) -/// * [delete http health checks](struct.HttpHealthCheckDeleteCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HttpHealthCheck { - /// [Output Only] Type of the resource. Always compute#httpHealthCheck for HTTP health checks. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// How long (in seconds) to wait before claiming failure. The default value is 5 seconds. It is invalid for timeoutSec to have greater value than checkIntervalSec. - #[serde(rename="timeoutSec")] - pub timeout_sec: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// How often (in seconds) to send a health check. The default value is 5 seconds. - #[serde(rename="checkIntervalSec")] - pub check_interval_sec: Option, - /// A so-far healthy instance will be marked unhealthy after this many consecutive failures. The default value is 2. - #[serde(rename="unhealthyThreshold")] - pub unhealthy_threshold: Option, - /// A so-far unhealthy instance will be marked healthy after this many consecutive successes. The default value is 2. - #[serde(rename="healthyThreshold")] - pub healthy_threshold: Option, - /// The value of the host header in the HTTP health check request. If left empty (default value), the public IP on behalf of which this health check is performed will be used. - pub host: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// The TCP port number for the HTTP health check request. The default value is 80. - pub port: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// The request path of the HTTP health check request. The default value is /. - #[serde(rename="requestPath")] - pub request_path: Option, -} - -impl RequestValue for HttpHealthCheck {} -impl Resource for HttpHealthCheck {} -impl ResponseResult for HttpHealthCheck {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AutoscalersScopedList { - /// [Output Only] Informational warning which replaces the list of autoscalers when the list is empty. - pub warning: Option, - /// [Output Only] List of autoscalers contained in this scope. - pub autoscalers: Option>, -} - -impl Part for AutoscalersScopedList {} - - -/// Represents a Route resource. A route specifies how certain packets should be handled by the network. Routes are associated with instances by tags and the set of routes for a particular instance is called its routing table. -/// -/// For each packet leaving a instance, the system searches that instance's routing table for a single best matching route. Routes match packets by destination IP address, preferring smaller or more specific ranges over larger ones. If there is a tie, the system selects the route with the smallest priority value. If there is still a tie, it uses the layer three and four packet headers to select just one of the remaining matching routes. The packet is then forwarded as specified by the nextHop field of the winning route - either to another instance destination, a instance gateway or a Google Compute Engine-operated gateway. -/// -/// Packets that do not match any route in the sending instance's routing table are dropped. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list routes](struct.RouteListCall.html) (none) -/// * [insert routes](struct.RouteInsertCall.html) (request) -/// * [delete routes](struct.RouteDeleteCall.html) (none) -/// * [get routes](struct.RouteGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Route { - /// The URL to a gateway that should handle matching packets. You can only specify the internet gateway using a full or partial valid URL: projects//global/gateways/default-internet-gateway - #[serde(rename="nextHopGateway")] - pub next_hop_gateway: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// A list of instance tags to which this route applies. - pub tags: Option>, - /// The URL of the local network if it should handle matching packets. - #[serde(rename="nextHopNetwork")] - pub next_hop_network: Option, - /// The destination range of outgoing packets that this route applies to. - #[serde(rename="destRange")] - pub dest_range: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// The network IP address of an instance that should handle matching packets. - #[serde(rename="nextHopIp")] - pub next_hop_ip: Option, - /// Fully-qualified URL of the network that this route applies to. - pub network: Option, - /// [Output Only] Type of this resource. Always compute#routes for Route resources. - pub kind: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, - /// The URL to an instance that should handle matching packets. You can specify this as a full or partial URL. For example: - /// https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances/ - #[serde(rename="nextHopInstance")] - pub next_hop_instance: Option, - /// [Output Only] If potential misconfigurations are detected for this route, this field will be populated with warning messages. - pub warnings: Option>, - /// The priority of this route. Priority is used to break ties in cases where there is more than one matching route of equal prefix length. In the case of two routes with equal prefix length, the one with the lowest-numbered priority value wins. Default value is 1000. Valid range is 0 through 65535. - pub priority: Option, - /// The URL to a VpnTunnel that should handle matching packets. - #[serde(rename="nextHopVpnTunnel")] - pub next_hop_vpn_tunnel: Option, - /// [Output Only] Server-defined fully-qualified URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl RequestValue for Route {} -impl Resource for Route {} -impl ResponseResult for Route {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetVpnGatewaysScopedList { - /// [Output Only] List of target vpn gateways contained in this scope. - #[serde(rename="targetVpnGateways")] - pub target_vpn_gateways: Option>, - /// [Output Only] Informational warning which replaces the list of addresses when the list is empty. - pub warning: Option, -} - -impl Part for TargetVpnGatewaysScopedList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set target forwarding rules](struct.ForwardingRuleSetTargetCall.html) (request) -/// * [set backup target pools](struct.TargetPoolSetBackupCall.html) (request) -/// * [set target global forwarding rules](struct.GlobalForwardingRuleSetTargetCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetReference { - /// no description provided - pub target: Option, -} - -impl RequestValue for TargetReference {} - - -/// A network interface resource attached to an instance. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct NetworkInterface { - /// An array of configurations for this interface. Currently, only one access config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, then this instance will have no external internet access. - #[serde(rename="accessConfigs")] - pub access_configs: Option>, - /// An IPv4 internal network address to assign to the instance for this network interface. If not specified by the user, an unused internal IP is assigned by the system. - #[serde(rename="networkIP")] - pub network_ip: Option, - /// [Output Only] The name of the network interface, generated by the server. For network devices, these are eth0, eth1, etc. - pub name: Option, - /// The URL of the Subnetwork resource for this instance. If the network resource is in legacy mode, do not provide this property. If the network is in auto subnet mode, providing the subnetwork is optional. If the network is in custom subnet mode, then this field should be specified. If you specify this property, you can specify the subnetwork as a full or partial URL. For example, the following are all valid URLs: - /// - https://www.googleapis.com/compute/v1/projects/project/regions/region/subnetworks/subnetwork - /// - regions/region/subnetworks/subnetwork - pub subnetwork: Option, - /// URL of the network resource for this instance. This is required for creating an instance but optional when creating a firewall rule. If not specified when creating a firewall rule, the default network is used: - /// - /// global/networks/default - /// - /// If you specify this property, you can specify the network as a full or partial URL. For example, the following are all valid URLs: - /// - https://www.googleapis.com/compute/v1/projects/project/global/networks/network - /// - projects/project/global/networks/network - /// - global/networks/default - pub network: Option, -} - -impl Part for NetworkInterface {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DisksScopedList { - /// [Output Only] List of disks contained in this scope. - pub disks: Option>, - /// [Output Only] Informational warning which replaces the list of disks when the list is empty. - pub warning: Option, -} - -impl Part for DisksScopedList {} - - -/// Contains a list of VpnTunnel resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list vpn tunnels](struct.VpnTunnelListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct VpnTunnelList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// [Output Only] A list of VpnTunnel resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#vpnTunnel for VPN tunnels. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for VpnTunnelList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get health target pools](struct.TargetPoolGetHealthCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPoolInstanceHealth { - /// [Output Only] Type of resource. Always compute#targetPoolInstanceHealth when checking the health of an instance. - pub kind: Option, - /// no description provided - #[serde(rename="healthStatus")] - pub health_status: Option>, -} - -impl ResponseResult for TargetPoolInstanceHealth {} - - -/// Contains a list of HealthCheck resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list health checks](struct.HealthCheckListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HealthCheckList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of HealthCheck resources. - pub items: Option>, - /// Type of resource. - pub kind: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for HealthCheckList {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetInstancesScopedList { - /// List of target instances contained in this scope. - #[serde(rename="targetInstances")] - pub target_instances: Option>, - /// Informational warning which replaces the list of addresses when the list is empty. - pub warning: Option, -} - -impl Part for TargetInstancesScopedList {} - - -/// A UrlMap resource. This resource defines the mapping from URL to the BackendService resource, based on the "longest-match" of the URL's host and path. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [update url maps](struct.UrlMapUpdateCall.html) (request) -/// * [insert url maps](struct.UrlMapInsertCall.html) (request) -/// * [list url maps](struct.UrlMapListCall.html) (none) -/// * [invalidate cache url maps](struct.UrlMapInvalidateCacheCall.html) (none) -/// * [delete url maps](struct.UrlMapDeleteCall.html) (none) -/// * [get url maps](struct.UrlMapGetCall.html) (response) -/// * [validate url maps](struct.UrlMapValidateCall.html) (none) -/// * [patch url maps](struct.UrlMapPatchCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UrlMap { - /// [Output Only] Type of the resource. Always compute#urlMaps for url maps. - pub kind: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// The URL of the BackendService resource if none of the hostRules match. - #[serde(rename="defaultService")] - pub default_service: Option, - /// The list of expected URL mappings. Request to update this UrlMap will succeed only if all of the test cases pass. - pub tests: Option>, - /// The list of HostRules to use against the URL. - #[serde(rename="hostRules")] - pub host_rules: Option>, - /// Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a UrlMap. An up-to-date fingerprint must be provided in order to update the UrlMap. - pub fingerprint: Option, - /// The list of named PathMatchers to use against the URL. - #[serde(rename="pathMatchers")] - pub path_matchers: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, -} - -impl RequestValue for UrlMap {} -impl Resource for UrlMap {} -impl ResponseResult for UrlMap {} - - -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RouteWarningsData { - /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). - pub key: Option, - /// [Output Only] A warning data value corresponding to the key. - pub value: Option, -} - -impl NestedType for RouteWarningsData {} -impl Part for RouteWarningsData {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupsScopedList { - /// [Output Only] An informational warning that replaces the list of instance groups when the list is empty. - pub warning: Option, - /// [Output Only] The list of instance groups that are contained in this scope. - #[serde(rename="instanceGroups")] - pub instance_groups: Option>, -} - -impl Part for InstanceGroupsScopedList {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set backend service target ssl proxies](struct.TargetSslProxySetBackendServiceCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetSslProxiesSetBackendServiceRequest { - /// The URL of the new BackendService resource for the targetSslProxy. - pub service: Option, -} - -impl RequestValue for TargetSslProxiesSetBackendServiceRequest {} - - -/// Contains a list of TargetPool resources. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list target pools](struct.TargetPoolListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPoolList { - /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of TargetPool resources. - pub items: Option>, - /// [Output Only] Type of resource. Always compute#targetPoolList for lists of target pools. - pub kind: Option, - /// [Output Only] Unique identifier for the resource. Defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for this resource. - #[serde(rename="selfLink")] - pub self_link: Option, -} - -impl ResponseResult for TargetPoolList {} - - -/// A Machine Type resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list machine types](struct.MachineTypeListCall.html) (none) -/// * [aggregated list machine types](struct.MachineTypeAggregatedListCall.html) (none) -/// * [get machine types](struct.MachineTypeGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MachineType { - /// [Output Only] The number of virtual CPUs that are available to the instance. - #[serde(rename="guestCpus")] - pub guest_cpus: Option, - /// [Deprecated] This property is deprecated and will never be populated with any relevant values. - #[serde(rename="imageSpaceGb")] - pub image_space_gb: Option, - /// [Output Only] The type of the resource. Always compute#machineType for machine types. - pub kind: Option, - /// [Output Only] An optional textual description of the resource. - pub description: Option, - /// [Output Only] The name of the zone where the machine type resides, such as us-central1-a. - pub zone: Option, - /// [Output Only] Maximum total persistent disks size (GB) allowed. - #[serde(rename="maximumPersistentDisksSizeGb")] - pub maximum_persistent_disks_size_gb: Option, - /// [Output Only] The deprecation status associated with this machine type. - pub deprecated: Option, - /// [Output Only] Maximum persistent disks allowed. - #[serde(rename="maximumPersistentDisks")] - pub maximum_persistent_disks: Option, - /// [Output Only] The amount of physical memory available to the instance, defined in MB. - #[serde(rename="memoryMb")] - pub memory_mb: Option, - /// [Output Only] Whether this machine type has a shared CPU. See Shared-core machine types for more information. - #[serde(rename="isSharedCpu")] - pub is_shared_cpu: Option, - /// [Output Only] List of extended scratch disks assigned to the instance. - #[serde(rename="scratchDisks")] - pub scratch_disks: Option>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// [Output Only] Name of the resource. - pub name: Option, -} - -impl Resource for MachineType {} -impl ResponseResult for MachineType {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [remove health check target pools](struct.TargetPoolRemoveHealthCheckCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPoolsRemoveHealthCheckRequest { - /// Health check URL to be removed. This can be a full or valid partial URL. For example, the following are valid URLs: - /// - https://www.googleapis.com/compute/beta/projects/project/global/httpHealthChecks/health-check - /// - projects/project/global/httpHealthChecks/health-check - /// - global/httpHealthChecks/health-check - #[serde(rename="healthChecks")] - pub health_checks: Option>, -} - -impl RequestValue for TargetPoolsRemoveHealthCheckRequest {} - - -/// A persistent disk snapshot resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list snapshots](struct.SnapshotListCall.html) (none) -/// * [create snapshot disks](struct.DiskCreateSnapshotCall.html) (request) -/// * [delete snapshots](struct.SnapshotDeleteCall.html) (none) -/// * [get snapshots](struct.SnapshotGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Snapshot { - /// [Output Only] The status of the snapshot. This can be CREATING, DELETING, FAILED, READY, or UPLOADING. - pub status: Option, - /// [Output Only] Type of the resource. Always compute#snapshot for Snapshot resources. - pub kind: Option, - /// The customer-supplied encryption key of the source disk. Required if the source disk is protected by a customer-supplied encryption key. - #[serde(rename="sourceDiskEncryptionKey")] - pub source_disk_encryption_key: Option, - /// [Output Only] A size of the the storage used by the snapshot. As snapshots share storage, this number is expected to change with snapshot creation/deletion. - #[serde(rename="storageBytes")] - pub storage_bytes: Option, - /// An optional description of this resource. Provide this property when you create the resource. - pub description: Option, - /// [Output Only] The source disk used to create this snapshot. - #[serde(rename="sourceDisk")] - pub source_disk: Option, - /// [Output Only] Size of the snapshot, specified in GB. - #[serde(rename="diskSizeGb")] - pub disk_size_gb: Option, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option, - /// [Output Only] The ID value of the disk used to create this snapshot. This value may be used to determine whether the snapshot was taken from the current or a previous instance of a given disk name. - #[serde(rename="sourceDiskId")] - pub source_disk_id: Option, - /// Encrypts the snapshot using a customer-supplied encryption key. - /// - /// After you encrypt a snapshot using a customer-supplied key, you must provide the same key if you use the image later For example, you must provide the encryption key when you create a disk from the encrypted snapshot in a future request. - /// - /// Customer-supplied encryption keys do not protect access to metadata of the disk. - /// - /// If you do not provide an encryption key when creating the snapshot, then the snapshot will be encrypted using an automatically generated key and you do not need to provide a key to use the snapshot later. - #[serde(rename="snapshotEncryptionKey")] - pub snapshot_encryption_key: Option, - /// [Output Only] A list of public visible licenses that apply to this snapshot. This can be because the original image had licenses attached (such as a Windows image). - pub licenses: Option>, - /// [Output Only] An indicator whether storageBytes is in a stable state or it is being adjusted as a result of shared storage reallocation. This status can either be UPDATING, meaning the size of the snapshot is being updated, or UP_TO_DATE, meaning the size of the snapshot is up-to-date. - #[serde(rename="storageBytesStatus")] - pub storage_bytes_status: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option, - /// Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - pub name: Option, -} - -impl RequestValue for Snapshot {} -impl Resource for Snapshot {} -impl ResponseResult for Snapshot {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set ssl certificates target ssl proxies](struct.TargetSslProxySetSslCertificateCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetSslProxiesSetSslCertificatesRequest { - /// New set of URLs to SslCertificate resources to associate with this TargetSslProxy. Currently exactly one ssl certificate must be specified. - #[serde(rename="sslCertificates")] - pub ssl_certificates: Option>, -} - -impl RequestValue for TargetSslProxiesSetSslCertificatesRequest {} - - -/// [Output Only] The array of errors encountered while processing this operation. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ManagedInstanceLastAttemptErrorsErrors { - /// [Output Only] An optional, human-readable error message. - pub message: Option, - /// [Output Only] The error type identifier for this error. - pub code: Option, - /// [Output Only] Indicates the field in the request that caused the error. This property is optional. - pub location: Option, -} - -impl NestedType for ManagedInstanceLastAttemptErrorsErrors {} -impl Part for ManagedInstanceLastAttemptErrorsErrors {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [validate url maps](struct.UrlMapValidateCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UrlMapsValidateResponse { - /// no description provided - pub result: Option, -} - -impl ResponseResult for UrlMapsValidateResponse {} - - -/// Sets the scheduling options for an Instance. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set scheduling instances](struct.InstanceSetSchedulingCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Scheduling { - /// Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user). You can only set the automatic restart option for standard instances. Preemptible instances cannot be automatically restarted. - #[serde(rename="automaticRestart")] - pub automatic_restart: Option, - /// Whether the instance is preemptible. - pub preemptible: Option, - /// Defines the maintenance behavior for this instance. For standard instances, the default behavior is MIGRATE. For preemptible instances, the default and only possible behavior is TERMINATE. For more information, see Setting Instance Scheduling Options. - #[serde(rename="onHostMaintenance")] - pub on_host_maintenance: Option, -} - -impl RequestValue for Scheduling {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetPoolsScopedList { - /// Informational warning which replaces the list of addresses when the list is empty. - pub warning: Option, - /// List of target pools contained in this scope. - #[serde(rename="targetPools")] - pub target_pools: Option>, -} - -impl Part for TargetPoolsScopedList {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InstanceGroupManagersScopedList { - /// [Output Only] The warning that replaces the list of managed instance groups when the list is empty. - pub warning: Option, - /// [Output Only] The list of managed instance groups that are contained in the specified project and zone. - #[serde(rename="instanceGroupManagers")] - pub instance_group_managers: Option>, -} - -impl Part for InstanceGroupManagersScopedList {} - - - -// ################### -// MethodBuilders ### -// ################# - -/// A builder providing access to all methods supported on *disk* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `create_snapshot(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)` and `resize(...)` -/// // to build up your call. -/// let rb = hub.disks(); -/// # } -/// ``` -pub struct DiskMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for DiskMethods<'a, C, A> {} - -impl<'a, C, A> DiskMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `disk` - Name of the persistent disk to delete. - pub fn delete(&self, project: &str, zone: &str, disk: &str) -> DiskDeleteCall<'a, C, A> { - DiskDeleteCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _disk: disk.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of persistent disks. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> DiskAggregatedListCall<'a, C, A> { - DiskAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns a specified persistent disk. Get a list of available persistent disks by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `disk` - Name of the persistent disk to return. - pub fn get(&self, project: &str, zone: &str, disk: &str) -> DiskGetCall<'a, C, A> { - DiskGetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _disk: disk.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of persistent disks contained within the specified zone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - pub fn list(&self, project: &str, zone: &str) -> DiskListCall<'a, C, A> { - DiskListCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Resizes the specified persistent disk. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `disk` - The name of the persistent disk. - pub fn resize(&self, request: DisksResizeRequest, project: &str, zone: &str, disk: &str) -> DiskResizeCall<'a, C, A> { - DiskResizeCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _disk: disk.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a persistent disk in the specified project using the data in the request. You can create a disk with a sourceImage, a sourceSnapshot, or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - pub fn insert(&self, request: Disk, project: &str, zone: &str) -> DiskInsertCall<'a, C, A> { - DiskInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _source_image: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a snapshot of a specified persistent disk. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `disk` - Name of the persistent disk to snapshot. - pub fn create_snapshot(&self, request: Snapshot, project: &str, zone: &str, disk: &str) -> DiskCreateSnapshotCall<'a, C, A> { - DiskCreateSnapshotCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _disk: disk.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *targetSslProxy* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `set_backend_service(...)`, `set_proxy_header(...)` and `set_ssl_certificates(...)` -/// // to build up your call. -/// let rb = hub.target_ssl_proxies(); -/// # } -/// ``` -pub struct TargetSslProxyMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for TargetSslProxyMethods<'a, C, A> {} - -impl<'a, C, A> TargetSslProxyMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of TargetSslProxy resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> TargetSslProxyListCall<'a, C, A> { - TargetSslProxyListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Changes SslCertificates for TargetSslProxy. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `targetSslProxy` - Name of the TargetSslProxy resource whose SslCertificate resource is to be set. - pub fn set_ssl_certificates(&self, request: TargetSslProxiesSetSslCertificatesRequest, project: &str, target_ssl_proxy: &str) -> TargetSslProxySetSslCertificateCall<'a, C, A> { - TargetSslProxySetSslCertificateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _target_ssl_proxy: target_ssl_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Changes the BackendService for TargetSslProxy. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `targetSslProxy` - Name of the TargetSslProxy resource whose BackendService resource is to be set. - pub fn set_backend_service(&self, request: TargetSslProxiesSetBackendServiceRequest, project: &str, target_ssl_proxy: &str) -> TargetSslProxySetBackendServiceCall<'a, C, A> { - TargetSslProxySetBackendServiceCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _target_ssl_proxy: target_ssl_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified TargetSslProxy resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `targetSslProxy` - Name of the TargetSslProxy resource to delete. - pub fn delete(&self, project: &str, target_ssl_proxy: &str) -> TargetSslProxyDeleteCall<'a, C, A> { - TargetSslProxyDeleteCall { - hub: self.hub, - _project: project.to_string(), - _target_ssl_proxy: target_ssl_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified TargetSslProxy resource. Get a list of available target SSL proxies by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `targetSslProxy` - Name of the TargetSslProxy resource to return. - pub fn get(&self, project: &str, target_ssl_proxy: &str) -> TargetSslProxyGetCall<'a, C, A> { - TargetSslProxyGetCall { - hub: self.hub, - _project: project.to_string(), - _target_ssl_proxy: target_ssl_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Changes the ProxyHeaderType for TargetSslProxy. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `targetSslProxy` - Name of the TargetSslProxy resource whose ProxyHeader is to be set. - pub fn set_proxy_header(&self, request: TargetSslProxiesSetProxyHeaderRequest, project: &str, target_ssl_proxy: &str) -> TargetSslProxySetProxyHeaderCall<'a, C, A> { - TargetSslProxySetProxyHeaderCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _target_ssl_proxy: target_ssl_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a TargetSslProxy resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: TargetSslProxy, project: &str) -> TargetSslProxyInsertCall<'a, C, A> { - TargetSslProxyInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *urlMap* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)`, `invalidate_cache(...)`, `list(...)`, `patch(...)`, `update(...)` and `validate(...)` -/// // to build up your call. -/// let rb = hub.url_maps(); -/// # } -/// ``` -pub struct UrlMapMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for UrlMapMethods<'a, C, A> {} - -impl<'a, C, A> UrlMapMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Creates a UrlMap resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: UrlMap, project: &str) -> UrlMapInsertCall<'a, C, A> { - UrlMapInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified UrlMap resource. Get a list of available URL maps by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `urlMap` - Name of the UrlMap resource to return. - pub fn get(&self, project: &str, url_map: &str) -> UrlMapGetCall<'a, C, A> { - UrlMapGetCall { - hub: self.hub, - _project: project.to_string(), - _url_map: url_map.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `urlMap` - Name of the UrlMap resource to be validated as. - pub fn validate(&self, request: UrlMapsValidateRequest, project: &str, url_map: &str) -> UrlMapValidateCall<'a, C, A> { - UrlMapValidateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _url_map: url_map.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of UrlMap resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> UrlMapListCall<'a, C, A> { - UrlMapListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `urlMap` - Name of the UrlMap scoping this request. - pub fn invalidate_cache(&self, request: CacheInvalidationRule, project: &str, url_map: &str) -> UrlMapInvalidateCacheCall<'a, C, A> { - UrlMapInvalidateCacheCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _url_map: url_map.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates the entire content of the UrlMap resource. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `urlMap` - Name of the UrlMap resource to update. - pub fn patch(&self, request: UrlMap, project: &str, url_map: &str) -> UrlMapPatchCall<'a, C, A> { - UrlMapPatchCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _url_map: url_map.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates the entire content of the UrlMap resource. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `urlMap` - Name of the UrlMap resource to update. - pub fn update(&self, request: UrlMap, project: &str, url_map: &str) -> UrlMapUpdateCall<'a, C, A> { - UrlMapUpdateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _url_map: url_map.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified UrlMap resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `urlMap` - Name of the UrlMap resource to delete. - pub fn delete(&self, project: &str, url_map: &str) -> UrlMapDeleteCall<'a, C, A> { - UrlMapDeleteCall { - hub: self.hub, - _project: project.to_string(), - _url_map: url_map.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *globalAddresse* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.global_addresses(); -/// # } -/// ``` -pub struct GlobalAddresseMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for GlobalAddresseMethods<'a, C, A> {} - -impl<'a, C, A> GlobalAddresseMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Creates an address resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: Address, project: &str) -> GlobalAddresseInsertCall<'a, C, A> { - GlobalAddresseInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of global addresses. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> GlobalAddresseListCall<'a, C, A> { - GlobalAddresseListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified address resource. Get a list of available addresses by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `address` - Name of the address resource to return. - pub fn get(&self, project: &str, address: &str) -> GlobalAddresseGetCall<'a, C, A> { - GlobalAddresseGetCall { - hub: self.hub, - _project: project.to_string(), - _address: address.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified address resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `address` - Name of the address resource to delete. - pub fn delete(&self, project: &str, address: &str) -> GlobalAddresseDeleteCall<'a, C, A> { - GlobalAddresseDeleteCall { - hub: self.hub, - _project: project.to_string(), - _address: address.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *snapshot* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.snapshots(); -/// # } -/// ``` -pub struct SnapshotMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for SnapshotMethods<'a, C, A> {} - -impl<'a, C, A> SnapshotMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified Snapshot resource. Get a list of available snapshots by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `snapshot` - Name of the Snapshot resource to return. - pub fn get(&self, project: &str, snapshot: &str) -> SnapshotGetCall<'a, C, A> { - SnapshotGetCall { - hub: self.hub, - _project: project.to_string(), - _snapshot: snapshot.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of Snapshot resources contained within the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> SnapshotListCall<'a, C, A> { - SnapshotListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot. - /// - /// For more information, see Deleting snaphots. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `snapshot` - Name of the Snapshot resource to delete. - pub fn delete(&self, project: &str, snapshot: &str) -> SnapshotDeleteCall<'a, C, A> { - SnapshotDeleteCall { - hub: self.hub, - _project: project.to_string(), - _snapshot: snapshot.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *diskType* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `get(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.disk_types(); -/// # } -/// ``` -pub struct DiskTypeMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for DiskTypeMethods<'a, C, A> {} - -impl<'a, C, A> DiskTypeMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified disk type. Get a list of available disk types by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `diskType` - Name of the disk type to return. - pub fn get(&self, project: &str, zone: &str, disk_type: &str) -> DiskTypeGetCall<'a, C, A> { - DiskTypeGetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _disk_type: disk_type.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of disk types. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> DiskTypeAggregatedListCall<'a, C, A> { - DiskTypeAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of disk types available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - pub fn list(&self, project: &str, zone: &str) -> DiskTypeListCall<'a, C, A> { - DiskTypeListCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *zone* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.zones(); -/// # } -/// ``` -pub struct ZoneMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for ZoneMethods<'a, C, A> {} - -impl<'a, C, A> ZoneMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified Zone resource. Get a list of available zones by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone resource to return. - pub fn get(&self, project: &str, zone: &str) -> ZoneGetCall<'a, C, A> { - ZoneGetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of Zone resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> ZoneListCall<'a, C, A> { - ZoneListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *instance* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `add_access_config(...)`, `aggregated_list(...)`, `attach_disk(...)`, `delete(...)`, `delete_access_config(...)`, `detach_disk(...)`, `get(...)`, `get_serial_port_output(...)`, `insert(...)`, `list(...)`, `reset(...)`, `set_disk_auto_delete(...)`, `set_machine_type(...)`, `set_metadata(...)`, `set_scheduling(...)`, `set_tags(...)`, `start(...)`, `start_with_encryption_key(...)` and `stop(...)` -/// // to build up your call. -/// let rb = hub.instances(); -/// # } -/// ``` -pub struct InstanceMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for InstanceMethods<'a, C, A> {} - -impl<'a, C, A> InstanceMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Changes the machine type for a stopped instance to the machine type specified in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Name of the instance scoping this request. - pub fn set_machine_type(&self, request: InstancesSetMachineTypeRequest, project: &str, zone: &str, instance: &str) -> InstanceSetMachineTypeCall<'a, C, A> { - InstanceSetMachineTypeCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Sets an instance's scheduling options. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Instance name. - pub fn set_scheduling(&self, request: Scheduling, project: &str, zone: &str, instance: &str) -> InstanceSetSchedulingCall<'a, C, A> { - InstanceSetSchedulingCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified Instance resource. For more information, see Stopping or Deleting an Instance. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Name of the instance resource to delete. - pub fn delete(&self, project: &str, zone: &str, instance: &str) -> InstanceDeleteCall<'a, C, A> { - InstanceDeleteCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified instance's serial port output. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Name of the instance scoping this request. - pub fn get_serial_port_output(&self, project: &str, zone: &str, instance: &str) -> InstanceGetSerialPortOutputCall<'a, C, A> { - InstanceGetSerialPortOutputCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _port: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Sets the auto-delete flag for a disk attached to an instance. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - The instance name. - /// * `autoDelete` - Whether to auto-delete the disk when the instance is deleted. - /// * `deviceName` - The device name of the disk to modify. - pub fn set_disk_auto_delete(&self, project: &str, zone: &str, instance: &str, auto_delete: bool, device_name: &str) -> InstanceSetDiskAutoDeleteCall<'a, C, A> { - InstanceSetDiskAutoDeleteCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _auto_delete: auto_delete, - _device_name: device_name.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Adds an access config to an instance's network interface. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - The instance name for this request. - /// * `networkInterface` - The name of the network interface to add to this instance. - pub fn add_access_config(&self, request: AccessConfig, project: &str, zone: &str, instance: &str, network_interface: &str) -> InstanceAddAccessConfigCall<'a, C, A> { - InstanceAddAccessConfigCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _network_interface: network_interface.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Sets metadata for the specified instance to the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Name of the instance scoping this request. - pub fn set_metadata(&self, request: Metadata, project: &str, zone: &str, instance: &str) -> InstanceSetMetadataCall<'a, C, A> { - InstanceSetMetadataCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Starts an instance that was stopped using the using the instances().stop method. For more information, see Restart an instance. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Name of the instance resource to start. - pub fn start(&self, project: &str, zone: &str, instance: &str) -> InstanceStartCall<'a, C, A> { - InstanceStartCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified Instance resource. Get a list of available instances by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Name of the instance resource to return. - pub fn get(&self, project: &str, zone: &str, instance: &str) -> InstanceGetCall<'a, C, A> { - InstanceGetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Sets tags for the specified instance to the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Name of the instance scoping this request. - pub fn set_tags(&self, request: Tags, project: &str, zone: &str, instance: &str) -> InstanceSetTagCall<'a, C, A> { - InstanceSetTagCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Detaches a disk from an instance. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Instance name. - /// * `deviceName` - Disk device name to detach. - pub fn detach_disk(&self, project: &str, zone: &str, instance: &str, device_name: &str) -> InstanceDetachDiskCall<'a, C, A> { - InstanceDetachDiskCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _device_name: device_name.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur per-minute, virtual machine usage charges while they are stopped, but any resources that the virtual machine is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Name of the instance resource to stop. - pub fn stop(&self, project: &str, zone: &str, instance: &str) -> InstanceStopCall<'a, C, A> { - InstanceStopCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates an instance resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - pub fn insert(&self, request: Instance, project: &str, zone: &str) -> InstanceInsertCall<'a, C, A> { - InstanceInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Performs a hard reset on the instance. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Name of the instance scoping this request. - pub fn reset(&self, project: &str, zone: &str, instance: &str) -> InstanceResetCall<'a, C, A> { - InstanceResetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes an access config from an instance's network interface. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - The instance name for this request. - /// * `accessConfig` - The name of the access config to delete. - /// * `networkInterface` - The name of the network interface. - pub fn delete_access_config(&self, project: &str, zone: &str, instance: &str, access_config: &str, network_interface: &str) -> InstanceDeleteAccessConfigCall<'a, C, A> { - InstanceDeleteAccessConfigCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _access_config: access_config.to_string(), - _network_interface: network_interface.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Attaches a Disk resource to an instance. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - The instance name for this request. - pub fn attach_disk(&self, request: AttachedDisk, project: &str, zone: &str, instance: &str) -> InstanceAttachDiskCall<'a, C, A> { - InstanceAttachDiskCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of instances contained within the specified zone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - pub fn list(&self, project: &str, zone: &str) -> InstanceListCall<'a, C, A> { - InstanceListCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Starts an instance that was stopped using the using the instances().stop method. For more information, see Restart an instance. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `instance` - Name of the instance resource to start. - pub fn start_with_encryption_key(&self, request: InstancesStartWithEncryptionKeyRequest, project: &str, zone: &str, instance: &str) -> InstanceStartWithEncryptionKeyCall<'a, C, A> { - InstanceStartWithEncryptionKeyCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance: instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves aggregated list of instances. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> InstanceAggregatedListCall<'a, C, A> { - InstanceAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *backendService* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `get_health(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` -/// // to build up your call. -/// let rb = hub.backend_services(); -/// # } -/// ``` -pub struct BackendServiceMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for BackendServiceMethods<'a, C, A> {} - -impl<'a, C, A> BackendServiceMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Gets the most recent health check results for this BackendService. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - No description provided. - /// * `backendService` - Name of the BackendService resource to which the queried instance belongs. - pub fn get_health(&self, request: ResourceGroupReference, project: &str, backend_service: &str) -> BackendServiceGetHealthCall<'a, C, A> { - BackendServiceGetHealthCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _backend_service: backend_service.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified BackendService resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `backendService` - Name of the BackendService resource to delete. - pub fn delete(&self, project: &str, backend_service: &str) -> BackendServiceDeleteCall<'a, C, A> { - BackendServiceDeleteCall { - hub: self.hub, - _project: project.to_string(), - _backend_service: backend_service.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified BackendService resource. Get a list of available backend services by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `backendService` - Name of the BackendService resource to return. - pub fn get(&self, project: &str, backend_service: &str) -> BackendServiceGetCall<'a, C, A> { - BackendServiceGetCall { - hub: self.hub, - _project: project.to_string(), - _backend_service: backend_service.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates the entire content of the BackendService resource. There are several restrictions and guidelines to keep in mind when updating a backend service. Read Restrictions and Guidelines for more information. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `backendService` - Name of the BackendService resource to update. - pub fn update(&self, request: BackendService, project: &str, backend_service: &str) -> BackendServiceUpdateCall<'a, C, A> { - BackendServiceUpdateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _backend_service: backend_service.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of BackendService resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> BackendServiceListCall<'a, C, A> { - BackendServiceListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates the entire content of the BackendService resource. There are several restrictions and guidelines to keep in mind when updating a backend service. Read Restrictions and Guidelines for more information. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `backendService` - Name of the BackendService resource to update. - pub fn patch(&self, request: BackendService, project: &str, backend_service: &str) -> BackendServicePatchCall<'a, C, A> { - BackendServicePatchCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _backend_service: backend_service.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a BackendService resource in the specified project using the data included in the request. There are several restrictions and guidelines to keep in mind when creating a backend service. Read Restrictions and Guidelines for more information. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: BackendService, project: &str) -> BackendServiceInsertCall<'a, C, A> { - BackendServiceInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *image* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `deprecate(...)`, `get(...)`, `get_from_family(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.images(); -/// # } -/// ``` -pub struct ImageMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for ImageMethods<'a, C, A> {} - -impl<'a, C, A> ImageMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of private images available to the specified project. Private images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> ImageListCall<'a, C, A> { - ImageListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the latest image that is part of an image family and is not deprecated. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `family` - Name of the image family to search for. - pub fn get_from_family(&self, project: &str, family: &str) -> ImageGetFromFamilyCall<'a, C, A> { - ImageGetFromFamilyCall { - hub: self.hub, - _project: project.to_string(), - _family: family.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified image. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `image` - Name of the image resource to delete. - pub fn delete(&self, project: &str, image: &str) -> ImageDeleteCall<'a, C, A> { - ImageDeleteCall { - hub: self.hub, - _project: project.to_string(), - _image: image.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Sets the deprecation status of an image. - /// - /// If an empty request body is given, clears the deprecation status instead. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `image` - Image name. - pub fn deprecate(&self, request: DeprecationStatus, project: &str, image: &str) -> ImageDeprecateCall<'a, C, A> { - ImageDeprecateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _image: image.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates an image in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: Image, project: &str) -> ImageInsertCall<'a, C, A> { - ImageInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified image. Get a list of available images by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `image` - Name of the image resource to return. - pub fn get(&self, project: &str, image: &str) -> ImageGetCall<'a, C, A> { - ImageGetCall { - hub: self.hub, - _project: project.to_string(), - _image: image.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *healthCheck* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` -/// // to build up your call. -/// let rb = hub.health_checks(); -/// # } -/// ``` -pub struct HealthCheckMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for HealthCheckMethods<'a, C, A> {} - -impl<'a, C, A> HealthCheckMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified HealthCheck resource. Get a list of available health checks by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `healthCheck` - Name of the HealthCheck resource to return. - pub fn get(&self, project: &str, health_check: &str) -> HealthCheckGetCall<'a, C, A> { - HealthCheckGetCall { - hub: self.hub, - _project: project.to_string(), - _health_check: health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates a HealthCheck resource in the specified project using the data included in the request. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `healthCheck` - Name of the HealthCheck resource to update. - pub fn patch(&self, request: HealthCheck, project: &str, health_check: &str) -> HealthCheckPatchCall<'a, C, A> { - HealthCheckPatchCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _health_check: health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a HealthCheck resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: HealthCheck, project: &str) -> HealthCheckInsertCall<'a, C, A> { - HealthCheckInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates a HealthCheck resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `healthCheck` - Name of the HealthCheck resource to update. - pub fn update(&self, request: HealthCheck, project: &str, health_check: &str) -> HealthCheckUpdateCall<'a, C, A> { - HealthCheckUpdateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _health_check: health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of HealthCheck resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> HealthCheckListCall<'a, C, A> { - HealthCheckListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified HealthCheck resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `healthCheck` - Name of the HealthCheck resource to delete. - pub fn delete(&self, project: &str, health_check: &str) -> HealthCheckDeleteCall<'a, C, A> { - HealthCheckDeleteCall { - hub: self.hub, - _project: project.to_string(), - _health_check: health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *license* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)` -/// // to build up your call. -/// let rb = hub.licenses(); -/// # } -/// ``` -pub struct LicenseMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for LicenseMethods<'a, C, A> {} - -impl<'a, C, A> LicenseMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified License resource. Get a list of available licenses by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `license` - Name of the License resource to return. - pub fn get(&self, project: &str, license: &str) -> LicenseGetCall<'a, C, A> { - LicenseGetCall { - hub: self.hub, - _project: project.to_string(), - _license: license.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *targetHttpsProxy* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `set_ssl_certificates(...)` and `set_url_map(...)` -/// // to build up your call. -/// let rb = hub.target_https_proxies(); -/// # } -/// ``` -pub struct TargetHttpsProxyMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for TargetHttpsProxyMethods<'a, C, A> {} - -impl<'a, C, A> TargetHttpsProxyMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified TargetHttpsProxy resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `targetHttpsProxy` - Name of the TargetHttpsProxy resource to delete. - pub fn delete(&self, project: &str, target_https_proxy: &str) -> TargetHttpsProxyDeleteCall<'a, C, A> { - TargetHttpsProxyDeleteCall { - hub: self.hub, - _project: project.to_string(), - _target_https_proxy: target_https_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified TargetHttpsProxy resource. Get a list of available target HTTPS proxies by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `targetHttpsProxy` - Name of the TargetHttpsProxy resource to return. - pub fn get(&self, project: &str, target_https_proxy: &str) -> TargetHttpsProxyGetCall<'a, C, A> { - TargetHttpsProxyGetCall { - hub: self.hub, - _project: project.to_string(), - _target_https_proxy: target_https_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Changes the URL map for TargetHttpsProxy. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `targetHttpsProxy` - Name of the TargetHttpsProxy resource whose URL map is to be set. - pub fn set_url_map(&self, request: UrlMapReference, project: &str, target_https_proxy: &str) -> TargetHttpsProxySetUrlMapCall<'a, C, A> { - TargetHttpsProxySetUrlMapCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _target_https_proxy: target_https_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a TargetHttpsProxy resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: TargetHttpsProxy, project: &str) -> TargetHttpsProxyInsertCall<'a, C, A> { - TargetHttpsProxyInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Replaces SslCertificates for TargetHttpsProxy. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `targetHttpsProxy` - Name of the TargetHttpsProxy resource to set an SslCertificates resource for. - pub fn set_ssl_certificates(&self, request: TargetHttpsProxiesSetSslCertificatesRequest, project: &str, target_https_proxy: &str) -> TargetHttpsProxySetSslCertificateCall<'a, C, A> { - TargetHttpsProxySetSslCertificateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _target_https_proxy: target_https_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of TargetHttpsProxy resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> TargetHttpsProxyListCall<'a, C, A> { - TargetHttpsProxyListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *network* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.networks(); -/// # } -/// ``` -pub struct NetworkMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for NetworkMethods<'a, C, A> {} - -impl<'a, C, A> NetworkMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Creates a network in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: Network, project: &str) -> NetworkInsertCall<'a, C, A> { - NetworkInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of networks available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> NetworkListCall<'a, C, A> { - NetworkListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified network. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `network` - Name of the network to delete. - pub fn delete(&self, project: &str, network: &str) -> NetworkDeleteCall<'a, C, A> { - NetworkDeleteCall { - hub: self.hub, - _project: project.to_string(), - _network: network.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified network. Get a list of available networks by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `network` - Name of the network to return. - pub fn get(&self, project: &str, network: &str) -> NetworkGetCall<'a, C, A> { - NetworkGetCall { - hub: self.hub, - _project: project.to_string(), - _network: network.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *addresse* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `delete(...)`, `get(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.addresses(); -/// # } -/// ``` -pub struct AddresseMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for AddresseMethods<'a, C, A> {} - -impl<'a, C, A> AddresseMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of addresses contained within the specified region. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - pub fn list(&self, project: &str, region: &str) -> AddresseListCall<'a, C, A> { - AddresseListCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of addresses. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> AddresseAggregatedListCall<'a, C, A> { - AddresseAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified address resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `address` - Name of the address resource to return. - pub fn get(&self, project: &str, region: &str, address: &str) -> AddresseGetCall<'a, C, A> { - AddresseGetCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _address: address.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates an address resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - pub fn insert(&self, request: Address, project: &str, region: &str) -> AddresseInsertCall<'a, C, A> { - AddresseInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified address resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `address` - Name of the address resource to delete. - pub fn delete(&self, project: &str, region: &str, address: &str) -> AddresseDeleteCall<'a, C, A> { - AddresseDeleteCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _address: address.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *globalOperation* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `delete(...)`, `get(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.global_operations(); -/// # } -/// ``` -pub struct GlobalOperationMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for GlobalOperationMethods<'a, C, A> {} - -impl<'a, C, A> GlobalOperationMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of Operation resources contained within the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> GlobalOperationListCall<'a, C, A> { - GlobalOperationListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the specified Operations resource. Get a list of operations by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `operation` - Name of the Operations resource to return. - pub fn get(&self, project: &str, operation: &str) -> GlobalOperationGetCall<'a, C, A> { - GlobalOperationGetCall { - hub: self.hub, - _project: project.to_string(), - _operation: operation.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified Operations resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `operation` - Name of the Operations resource to delete. - pub fn delete(&self, project: &str, operation: &str) -> GlobalOperationDeleteCall<'a, C, A> { - GlobalOperationDeleteCall { - hub: self.hub, - _project: project.to_string(), - _operation: operation.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of all operations. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> GlobalOperationAggregatedListCall<'a, C, A> { - GlobalOperationAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *autoscaler* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` -/// // to build up your call. -/// let rb = hub.autoscalers(); -/// # } -/// ``` -pub struct AutoscalerMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for AutoscalerMethods<'a, C, A> {} - -impl<'a, C, A> AutoscalerMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified autoscaler. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone for this request. - /// * `autoscaler` - Name of the autoscaler to delete. - pub fn delete(&self, project: &str, zone: &str, autoscaler: &str) -> AutoscalerDeleteCall<'a, C, A> { - AutoscalerDeleteCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _autoscaler: autoscaler.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified autoscaler resource. Get a list of available autoscalers by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone for this request. - /// * `autoscaler` - Name of the autoscaler to return. - pub fn get(&self, project: &str, zone: &str, autoscaler: &str) -> AutoscalerGetCall<'a, C, A> { - AutoscalerGetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _autoscaler: autoscaler.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of autoscalers contained within the specified zone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone for this request. - pub fn list(&self, project: &str, zone: &str) -> AutoscalerListCall<'a, C, A> { - AutoscalerListCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates an autoscaler in the specified project using the data included in the request. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone for this request. - /// * `autoscaler` - Name of the autoscaler to update. - pub fn patch(&self, request: Autoscaler, project: &str, zone: &str, autoscaler: &str) -> AutoscalerPatchCall<'a, C, A> { - AutoscalerPatchCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _autoscaler: autoscaler.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates an autoscaler in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone for this request. - pub fn insert(&self, request: Autoscaler, project: &str, zone: &str) -> AutoscalerInsertCall<'a, C, A> { - AutoscalerInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of autoscalers. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> AutoscalerAggregatedListCall<'a, C, A> { - AutoscalerAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates an autoscaler in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone for this request. - pub fn update(&self, request: Autoscaler, project: &str, zone: &str) -> AutoscalerUpdateCall<'a, C, A> { - AutoscalerUpdateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _autoscaler: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *subnetwork* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `delete(...)`, `get(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.subnetworks(); -/// # } -/// ``` -pub struct SubnetworkMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for SubnetworkMethods<'a, C, A> {} - -impl<'a, C, A> SubnetworkMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Creates a subnetwork in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - pub fn insert(&self, request: Subnetwork, project: &str, region: &str) -> SubnetworkInsertCall<'a, C, A> { - SubnetworkInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified subnetwork. Get a list of available subnetworks list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `subnetwork` - Name of the Subnetwork resource to return. - pub fn get(&self, project: &str, region: &str, subnetwork: &str) -> SubnetworkGetCall<'a, C, A> { - SubnetworkGetCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _subnetwork: subnetwork.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of subnetworks. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> SubnetworkAggregatedListCall<'a, C, A> { - SubnetworkAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified subnetwork. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `subnetwork` - Name of the Subnetwork resource to delete. - pub fn delete(&self, project: &str, region: &str, subnetwork: &str) -> SubnetworkDeleteCall<'a, C, A> { - SubnetworkDeleteCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _subnetwork: subnetwork.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of subnetworks available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - pub fn list(&self, project: &str, region: &str) -> SubnetworkListCall<'a, C, A> { - SubnetworkListCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *instanceGroup* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `add_instances(...)`, `aggregated_list(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `list_instances(...)`, `remove_instances(...)` and `set_named_ports(...)` -/// // to build up your call. -/// let rb = hub.instance_groups(); -/// # } -/// ``` -pub struct InstanceGroupMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for InstanceGroupMethods<'a, C, A> {} - -impl<'a, C, A> InstanceGroupMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the instance group is located. - /// * `instanceGroup` - The name of the instance group to delete. - pub fn delete(&self, project: &str, zone: &str, instance_group: &str) -> InstanceGroupDeleteCall<'a, C, A> { - InstanceGroupDeleteCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group: instance_group.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists the instances in the specified instance group. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the instance group is located. - /// * `instanceGroup` - The name of the instance group from which you want to generate a list of included instances. - pub fn list_instances(&self, request: InstanceGroupsListInstancesRequest, project: &str, zone: &str, instance_group: &str) -> InstanceGroupListInstanceCall<'a, C, A> { - InstanceGroupListInstanceCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group: instance_group.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the instance group is located. - /// * `instanceGroup` - The name of the instance group where you are adding instances. - pub fn add_instances(&self, request: InstanceGroupsAddInstancesRequest, project: &str, zone: &str, instance_group: &str) -> InstanceGroupAddInstanceCall<'a, C, A> { - InstanceGroupAddInstanceCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group: instance_group.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates an instance group in the specified project using the parameters that are included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where you want to create the instance group. - pub fn insert(&self, request: InstanceGroup, project: &str, zone: &str) -> InstanceGroupInsertCall<'a, C, A> { - InstanceGroupInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified instance group. Get a list of available instance groups by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the instance group is located. - /// * `instanceGroup` - The name of the instance group. - pub fn get(&self, project: &str, zone: &str, instance_group: &str) -> InstanceGroupGetCall<'a, C, A> { - InstanceGroupGetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group: instance_group.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Removes one or more instances from the specified instance group, but does not delete those instances. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the instance group is located. - /// * `instanceGroup` - The name of the instance group where the specified instances will be removed. - pub fn remove_instances(&self, request: InstanceGroupsRemoveInstancesRequest, project: &str, zone: &str, instance_group: &str) -> InstanceGroupRemoveInstanceCall<'a, C, A> { - InstanceGroupRemoveInstanceCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group: instance_group.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Sets the named ports for the specified instance group. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the instance group is located. - /// * `instanceGroup` - The name of the instance group where the named ports are updated. - pub fn set_named_ports(&self, request: InstanceGroupsSetNamedPortsRequest, project: &str, zone: &str, instance_group: &str) -> InstanceGroupSetNamedPortCall<'a, C, A> { - InstanceGroupSetNamedPortCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group: instance_group.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of instance groups and sorts them by zone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> InstanceGroupAggregatedListCall<'a, C, A> { - InstanceGroupAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of instance groups that are located in the specified project and zone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the instance group is located. - pub fn list(&self, project: &str, zone: &str) -> InstanceGroupListCall<'a, C, A> { - InstanceGroupListCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *region* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.regions(); -/// # } -/// ``` -pub struct RegionMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for RegionMethods<'a, C, A> {} - -impl<'a, C, A> RegionMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of region resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> RegionListCall<'a, C, A> { - RegionListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified Region resource. Get a list of available regions by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region resource to return. - pub fn get(&self, project: &str, region: &str) -> RegionGetCall<'a, C, A> { - RegionGetCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *forwardingRule* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)` and `set_target(...)` -/// // to build up your call. -/// let rb = hub.forwarding_rules(); -/// # } -/// ``` -pub struct ForwardingRuleMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for ForwardingRuleMethods<'a, C, A> {} - -impl<'a, C, A> ForwardingRuleMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of forwarding rules. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> ForwardingRuleAggregatedListCall<'a, C, A> { - ForwardingRuleAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a ForwardingRule resource in the specified project and region using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - pub fn insert(&self, request: ForwardingRule, project: &str, region: &str) -> ForwardingRuleInsertCall<'a, C, A> { - ForwardingRuleInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Changes target URL for forwarding rule. The new target should be of the same type as the old target. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `forwardingRule` - Name of the ForwardingRule resource in which target is to be set. - pub fn set_target(&self, request: TargetReference, project: &str, region: &str, forwarding_rule: &str) -> ForwardingRuleSetTargetCall<'a, C, A> { - ForwardingRuleSetTargetCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _forwarding_rule: forwarding_rule.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of ForwardingRule resources available to the specified project and region. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - pub fn list(&self, project: &str, region: &str) -> ForwardingRuleListCall<'a, C, A> { - ForwardingRuleListCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified ForwardingRule resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `forwardingRule` - Name of the ForwardingRule resource to return. - pub fn get(&self, project: &str, region: &str, forwarding_rule: &str) -> ForwardingRuleGetCall<'a, C, A> { - ForwardingRuleGetCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _forwarding_rule: forwarding_rule.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified ForwardingRule resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `forwardingRule` - Name of the ForwardingRule resource to delete. - pub fn delete(&self, project: &str, region: &str, forwarding_rule: &str) -> ForwardingRuleDeleteCall<'a, C, A> { - ForwardingRuleDeleteCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _forwarding_rule: forwarding_rule.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *targetPool* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `add_health_check(...)`, `add_instance(...)`, `aggregated_list(...)`, `delete(...)`, `get(...)`, `get_health(...)`, `insert(...)`, `list(...)`, `remove_health_check(...)`, `remove_instance(...)` and `set_backup(...)` -/// // to build up your call. -/// let rb = hub.target_pools(); -/// # } -/// ``` -pub struct TargetPoolMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for TargetPoolMethods<'a, C, A> {} - -impl<'a, C, A> TargetPoolMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Adds health check URLs to a target pool. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `targetPool` - Name of the target pool to add a health check to. - pub fn add_health_check(&self, request: TargetPoolsAddHealthCheckRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolAddHealthCheckCall<'a, C, A> { - TargetPoolAddHealthCheckCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _target_pool: target_pool.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a target pool in the specified project and region using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - pub fn insert(&self, request: TargetPool, project: &str, region: &str) -> TargetPoolInsertCall<'a, C, A> { - TargetPoolInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Removes health check URL from a target pool. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `targetPool` - Name of the target pool to remove health checks from. - pub fn remove_health_check(&self, request: TargetPoolsRemoveHealthCheckRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolRemoveHealthCheckCall<'a, C, A> { - TargetPoolRemoveHealthCheckCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _target_pool: target_pool.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Gets the most recent health check results for each IP for the instance that is referenced by the given target pool. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `targetPool` - Name of the TargetPool resource to which the queried instance belongs. - pub fn get_health(&self, request: InstanceReference, project: &str, region: &str, target_pool: &str) -> TargetPoolGetHealthCall<'a, C, A> { - TargetPoolGetHealthCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _target_pool: target_pool.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Changes a backup target pool's configurations. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `targetPool` - Name of the TargetPool resource to set a backup pool for. - pub fn set_backup(&self, request: TargetReference, project: &str, region: &str, target_pool: &str) -> TargetPoolSetBackupCall<'a, C, A> { - TargetPoolSetBackupCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _target_pool: target_pool.to_string(), - _failover_ratio: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of target pools. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> TargetPoolAggregatedListCall<'a, C, A> { - TargetPoolAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified target pool. Get a list of available target pools by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `targetPool` - Name of the TargetPool resource to return. - pub fn get(&self, project: &str, region: &str, target_pool: &str) -> TargetPoolGetCall<'a, C, A> { - TargetPoolGetCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _target_pool: target_pool.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Adds an instance to a target pool. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `targetPool` - Name of the TargetPool resource to add instances to. - pub fn add_instance(&self, request: TargetPoolsAddInstanceRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolAddInstanceCall<'a, C, A> { - TargetPoolAddInstanceCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _target_pool: target_pool.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Removes instance URL from a target pool. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `targetPool` - Name of the TargetPool resource to remove instances from. - pub fn remove_instance(&self, request: TargetPoolsRemoveInstanceRequest, project: &str, region: &str, target_pool: &str) -> TargetPoolRemoveInstanceCall<'a, C, A> { - TargetPoolRemoveInstanceCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _target_pool: target_pool.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified target pool. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - /// * `targetPool` - Name of the TargetPool resource to delete. - pub fn delete(&self, project: &str, region: &str, target_pool: &str) -> TargetPoolDeleteCall<'a, C, A> { - TargetPoolDeleteCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _target_pool: target_pool.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of target pools available to the specified project and region. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region scoping this request. - pub fn list(&self, project: &str, region: &str) -> TargetPoolListCall<'a, C, A> { - TargetPoolListCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *targetInstance* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `delete(...)`, `get(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.target_instances(); -/// # } -/// ``` -pub struct TargetInstanceMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for TargetInstanceMethods<'a, C, A> {} - -impl<'a, C, A> TargetInstanceMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of TargetInstance resources available to the specified project and zone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone scoping this request. - pub fn list(&self, project: &str, zone: &str) -> TargetInstanceListCall<'a, C, A> { - TargetInstanceListCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a TargetInstance resource in the specified project and zone using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone scoping this request. - pub fn insert(&self, request: TargetInstance, project: &str, zone: &str) -> TargetInstanceInsertCall<'a, C, A> { - TargetInstanceInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of target instances. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> TargetInstanceAggregatedListCall<'a, C, A> { - TargetInstanceAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified TargetInstance resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone scoping this request. - /// * `targetInstance` - Name of the TargetInstance resource to delete. - pub fn delete(&self, project: &str, zone: &str, target_instance: &str) -> TargetInstanceDeleteCall<'a, C, A> { - TargetInstanceDeleteCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _target_instance: target_instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified TargetInstance resource. Get a list of available target instances by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone scoping this request. - /// * `targetInstance` - Name of the TargetInstance resource to return. - pub fn get(&self, project: &str, zone: &str, target_instance: &str) -> TargetInstanceGetCall<'a, C, A> { - TargetInstanceGetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _target_instance: target_instance.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *globalForwardingRule* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)` and `set_target(...)` -/// // to build up your call. -/// let rb = hub.global_forwarding_rules(); -/// # } -/// ``` -pub struct GlobalForwardingRuleMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for GlobalForwardingRuleMethods<'a, C, A> {} - -impl<'a, C, A> GlobalForwardingRuleMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified ForwardingRule resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `forwardingRule` - Name of the ForwardingRule resource to delete. - pub fn delete(&self, project: &str, forwarding_rule: &str) -> GlobalForwardingRuleDeleteCall<'a, C, A> { - GlobalForwardingRuleDeleteCall { - hub: self.hub, - _project: project.to_string(), - _forwarding_rule: forwarding_rule.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Changes target URL for forwarding rule. The new target should be of the same type as the old target. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `forwardingRule` - Name of the ForwardingRule resource in which target is to be set. - pub fn set_target(&self, request: TargetReference, project: &str, forwarding_rule: &str) -> GlobalForwardingRuleSetTargetCall<'a, C, A> { - GlobalForwardingRuleSetTargetCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _forwarding_rule: forwarding_rule.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a ForwardingRule resource in the specified project and region using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: ForwardingRule, project: &str) -> GlobalForwardingRuleInsertCall<'a, C, A> { - GlobalForwardingRuleInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of ForwardingRule resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> GlobalForwardingRuleListCall<'a, C, A> { - GlobalForwardingRuleListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified ForwardingRule resource. Get a list of available forwarding rules by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `forwardingRule` - Name of the ForwardingRule resource to return. - pub fn get(&self, project: &str, forwarding_rule: &str) -> GlobalForwardingRuleGetCall<'a, C, A> { - GlobalForwardingRuleGetCall { - hub: self.hub, - _project: project.to_string(), - _forwarding_rule: forwarding_rule.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *httpsHealthCheck* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` -/// // to build up your call. -/// let rb = hub.https_health_checks(); -/// # } -/// ``` -pub struct HttpsHealthCheckMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for HttpsHealthCheckMethods<'a, C, A> {} - -impl<'a, C, A> HttpsHealthCheckMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified HttpsHealthCheck resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `httpsHealthCheck` - Name of the HttpsHealthCheck resource to delete. - pub fn delete(&self, project: &str, https_health_check: &str) -> HttpsHealthCheckDeleteCall<'a, C, A> { - HttpsHealthCheckDeleteCall { - hub: self.hub, - _project: project.to_string(), - _https_health_check: https_health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of HttpsHealthCheck resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> HttpsHealthCheckListCall<'a, C, A> { - HttpsHealthCheckListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a HttpsHealthCheck resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: HttpsHealthCheck, project: &str) -> HttpsHealthCheckInsertCall<'a, C, A> { - HttpsHealthCheckInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified HttpsHealthCheck resource. Get a list of available HTTPS health checks by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `httpsHealthCheck` - Name of the HttpsHealthCheck resource to return. - pub fn get(&self, project: &str, https_health_check: &str) -> HttpsHealthCheckGetCall<'a, C, A> { - HttpsHealthCheckGetCall { - hub: self.hub, - _project: project.to_string(), - _https_health_check: https_health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates a HttpsHealthCheck resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `httpsHealthCheck` - Name of the HttpsHealthCheck resource to update. - pub fn update(&self, request: HttpsHealthCheck, project: &str, https_health_check: &str) -> HttpsHealthCheckUpdateCall<'a, C, A> { - HttpsHealthCheckUpdateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _https_health_check: https_health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates a HttpsHealthCheck resource in the specified project using the data included in the request. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `httpsHealthCheck` - Name of the HttpsHealthCheck resource to update. - pub fn patch(&self, request: HttpsHealthCheck, project: &str, https_health_check: &str) -> HttpsHealthCheckPatchCall<'a, C, A> { - HttpsHealthCheckPatchCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _https_health_check: https_health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *router* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `delete(...)`, `get(...)`, `get_router_status(...)`, `insert(...)`, `list(...)`, `patch(...)`, `preview(...)` and `update(...)` -/// // to build up your call. -/// let rb = hub.routers(); -/// # } -/// ``` -pub struct RouterMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for RouterMethods<'a, C, A> {} - -impl<'a, C, A> RouterMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of routers. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> RouterAggregatedListCall<'a, C, A> { - RouterAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified Router resource. Get a list of available routers by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `router` - Name of the Router resource to return. - pub fn get(&self, project: &str, region: &str, router: &str) -> RouterGetCall<'a, C, A> { - RouterGetCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _router: router.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of Router resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - pub fn list(&self, project: &str, region: &str) -> RouterListCall<'a, C, A> { - RouterListCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves runtime information of the specified router. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `router` - Name of the Router resource to query. - pub fn get_router_status(&self, project: &str, region: &str, router: &str) -> RouterGetRouterStatuCall<'a, C, A> { - RouterGetRouterStatuCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _router: router.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates the entire content of the Router resource. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `router` - Name of the Router resource to update. - pub fn patch(&self, request: Router, project: &str, region: &str, router: &str) -> RouterPatchCall<'a, C, A> { - RouterPatchCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _router: router.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified Router resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `router` - Name of the Router resource to delete. - pub fn delete(&self, project: &str, region: &str, router: &str) -> RouterDeleteCall<'a, C, A> { - RouterDeleteCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _router: router.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a Router resource in the specified project and region using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - pub fn insert(&self, request: Router, project: &str, region: &str) -> RouterInsertCall<'a, C, A> { - RouterInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates the entire content of the Router resource. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `router` - Name of the Router resource to update. - pub fn update(&self, request: Router, project: &str, region: &str, router: &str) -> RouterUpdateCall<'a, C, A> { - RouterUpdateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _router: router.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Preview fields auto-generated during router create and update operations. Calling this method does NOT create or update the router. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `router` - Name of the Router resource to query. - pub fn preview(&self, request: Router, project: &str, region: &str, router: &str) -> RouterPreviewCall<'a, C, A> { - RouterPreviewCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _router: router.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *machineType* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `get(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.machine_types(); -/// # } -/// ``` -pub struct MachineTypeMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for MachineTypeMethods<'a, C, A> {} - -impl<'a, C, A> MachineTypeMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of machine types. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> MachineTypeAggregatedListCall<'a, C, A> { - MachineTypeAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified machine type. Get a list of available machine types by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - /// * `machineType` - Name of the machine type to return. - pub fn get(&self, project: &str, zone: &str, machine_type: &str) -> MachineTypeGetCall<'a, C, A> { - MachineTypeGetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _machine_type: machine_type.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of machine types available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone for this request. - pub fn list(&self, project: &str, zone: &str) -> MachineTypeListCall<'a, C, A> { - MachineTypeListCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *targetVpnGateway* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `delete(...)`, `get(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.target_vpn_gateways(); -/// # } -/// ``` -pub struct TargetVpnGatewayMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for TargetVpnGatewayMethods<'a, C, A> {} - -impl<'a, C, A> TargetVpnGatewayMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of target VPN gateways. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> TargetVpnGatewayAggregatedListCall<'a, C, A> { - TargetVpnGatewayAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified target VPN gateway. Get a list of available target VPN gateways by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `targetVpnGateway` - Name of the target VPN gateway to return. - pub fn get(&self, project: &str, region: &str, target_vpn_gateway: &str) -> TargetVpnGatewayGetCall<'a, C, A> { - TargetVpnGatewayGetCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _target_vpn_gateway: target_vpn_gateway.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of target VPN gateways available to the specified project and region. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - pub fn list(&self, project: &str, region: &str) -> TargetVpnGatewayListCall<'a, C, A> { - TargetVpnGatewayListCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a target VPN gateway in the specified project and region using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - pub fn insert(&self, request: TargetVpnGateway, project: &str, region: &str) -> TargetVpnGatewayInsertCall<'a, C, A> { - TargetVpnGatewayInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified target VPN gateway. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `targetVpnGateway` - Name of the target VPN gateway to delete. - pub fn delete(&self, project: &str, region: &str, target_vpn_gateway: &str) -> TargetVpnGatewayDeleteCall<'a, C, A> { - TargetVpnGatewayDeleteCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _target_vpn_gateway: target_vpn_gateway.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *instanceGroupManager* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `abandon_instances(...)`, `aggregated_list(...)`, `delete(...)`, `delete_instances(...)`, `get(...)`, `insert(...)`, `list(...)`, `list_managed_instances(...)`, `recreate_instances(...)`, `resize(...)`, `set_instance_template(...)` and `set_target_pools(...)` -/// // to build up your call. -/// let rb = hub.instance_group_managers(); -/// # } -/// ``` -pub struct InstanceGroupManagerMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for InstanceGroupManagerMethods<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the managed instance group is located. - /// * `instanceGroupManager` - The name of the managed instance group. - /// * `size` - The number of running instances that the managed instance group should maintain at any given time. The group automatically adds or removes instances to maintain the number of instances specified by this parameter. - pub fn resize(&self, project: &str, zone: &str, instance_group_manager: &str, size: i32) -> InstanceGroupManagerResizeCall<'a, C, A> { - InstanceGroupManagerResizeCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group_manager: instance_group_manager.to_string(), - _size: size, - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the managed instance group is located. - /// * `instanceGroupManager` - The name of the managed instance group. - pub fn list_managed_instances(&self, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerListManagedInstanceCall<'a, C, A> { - InstanceGroupManagerListManagedInstanceCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group_manager: instance_group_manager.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a managed instance group using the information that you specify in the request. After the group is created, it schedules an action to create instances in the group using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where you want to create the managed instance group. - pub fn insert(&self, request: InstanceGroupManager, project: &str, zone: &str) -> InstanceGroupManagerInsertCall<'a, C, A> { - InstanceGroupManagerInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of managed instance groups and groups them by zone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> InstanceGroupManagerAggregatedListCall<'a, C, A> { - InstanceGroupManagerAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Schedules a group action to delete the specified instances in the managed instance group. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the managed instance group is located. - /// * `instanceGroupManager` - The name of the managed instance group. - pub fn delete_instances(&self, request: InstanceGroupManagersDeleteInstancesRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> { - InstanceGroupManagerDeleteInstanceCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group_manager: instance_group_manager.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of managed instance groups that are contained within the specified project and zone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the managed instance group is located. - pub fn list(&self, project: &str, zone: &str) -> InstanceGroupManagerListCall<'a, C, A> { - InstanceGroupManagerListCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the managed instance group is located. - /// * `instanceGroupManager` - The name of the managed instance group. - pub fn set_target_pools(&self, request: InstanceGroupManagersSetTargetPoolsRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> { - InstanceGroupManagerSetTargetPoolCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group_manager: instance_group_manager.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you recreate them. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the managed instance group is located. - /// * `instanceGroupManager` - The name of the managed instance group. - pub fn set_instance_template(&self, request: InstanceGroupManagersSetInstanceTemplateRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> { - InstanceGroupManagerSetInstanceTemplateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group_manager: instance_group_manager.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the managed instance group is located. - /// * `instanceGroupManager` - The name of the managed instance group to delete. - pub fn delete(&self, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerDeleteCall<'a, C, A> { - InstanceGroupManagerDeleteCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group_manager: instance_group_manager.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns all of the details about the specified managed instance group. Get a list of available managed instance groups by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the managed instance group is located. - /// * `instanceGroupManager` - The name of the managed instance group. - pub fn get(&self, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerGetCall<'a, C, A> { - InstanceGroupManagerGetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group_manager: instance_group_manager.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Schedules a group action to remove the specified instances from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the managed instance group is located. - /// * `instanceGroupManager` - The name of the managed instance group. - pub fn abandon_instances(&self, request: InstanceGroupManagersAbandonInstancesRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> { - InstanceGroupManagerAbandonInstanceCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group_manager: instance_group_manager.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Schedules a group action to recreate the specified instances in the managed instance group. The instances are deleted and recreated using the current instance template for the managed instance group. This operation is marked as DONE when the action is scheduled even if the instances have not yet been recreated. You must separately verify the status of the recreating action with the listmanagedinstances method. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `zone` - The name of the zone where the managed instance group is located. - /// * `instanceGroupManager` - The name of the managed instance group. - pub fn recreate_instances(&self, request: InstanceGroupManagersRecreateInstancesRequest, project: &str, zone: &str, instance_group_manager: &str) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> { - InstanceGroupManagerRecreateInstanceCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _zone: zone.to_string(), - _instance_group_manager: instance_group_manager.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *project* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)`, `move_disk(...)`, `move_instance(...)`, `set_common_instance_metadata(...)` and `set_usage_export_bucket(...)` -/// // to build up your call. -/// let rb = hub.projects(); -/// # } -/// ``` -pub struct ProjectMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for ProjectMethods<'a, C, A> {} - -impl<'a, C, A> ProjectMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Moves a persistent disk from one zone to another. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn move_disk(&self, request: DiskMoveRequest, project: &str) -> ProjectMoveDiskCall<'a, C, A> { - ProjectMoveDiskCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Sets metadata common to all instances within the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn set_common_instance_metadata(&self, request: Metadata, project: &str) -> ProjectSetCommonInstanceMetadataCall<'a, C, A> { - ProjectSetCommonInstanceMetadataCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Moves an instance and its attached persistent disks from one zone to another. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn move_instance(&self, request: InstanceMoveRequest, project: &str) -> ProjectMoveInstanceCall<'a, C, A> { - ProjectMoveInstanceCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide an empty request body using this method, the usage export feature will be disabled. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn set_usage_export_bucket(&self, request: UsageExportLocation, project: &str) -> ProjectSetUsageExportBucketCall<'a, C, A> { - ProjectSetUsageExportBucketCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified Project resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn get(&self, project: &str) -> ProjectGetCall<'a, C, A> { - ProjectGetCall { - hub: self.hub, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *httpHealthCheck* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` -/// // to build up your call. -/// let rb = hub.http_health_checks(); -/// # } -/// ``` -pub struct HttpHealthCheckMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for HttpHealthCheckMethods<'a, C, A> {} - -impl<'a, C, A> HttpHealthCheckMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified HttpHealthCheck resource. Get a list of available HTTP health checks by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `httpHealthCheck` - Name of the HttpHealthCheck resource to return. - pub fn get(&self, project: &str, http_health_check: &str) -> HttpHealthCheckGetCall<'a, C, A> { - HttpHealthCheckGetCall { - hub: self.hub, - _project: project.to_string(), - _http_health_check: http_health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified HttpHealthCheck resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `httpHealthCheck` - Name of the HttpHealthCheck resource to delete. - pub fn delete(&self, project: &str, http_health_check: &str) -> HttpHealthCheckDeleteCall<'a, C, A> { - HttpHealthCheckDeleteCall { - hub: self.hub, - _project: project.to_string(), - _http_health_check: http_health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates a HttpHealthCheck resource in the specified project using the data included in the request. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `httpHealthCheck` - Name of the HttpHealthCheck resource to update. - pub fn patch(&self, request: HttpHealthCheck, project: &str, http_health_check: &str) -> HttpHealthCheckPatchCall<'a, C, A> { - HttpHealthCheckPatchCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _http_health_check: http_health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of HttpHealthCheck resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> HttpHealthCheckListCall<'a, C, A> { - HttpHealthCheckListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a HttpHealthCheck resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: HttpHealthCheck, project: &str) -> HttpHealthCheckInsertCall<'a, C, A> { - HttpHealthCheckInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates a HttpHealthCheck resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `httpHealthCheck` - Name of the HttpHealthCheck resource to update. - pub fn update(&self, request: HttpHealthCheck, project: &str, http_health_check: &str) -> HttpHealthCheckUpdateCall<'a, C, A> { - HttpHealthCheckUpdateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _http_health_check: http_health_check.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *instanceTemplate* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.instance_templates(); -/// # } -/// ``` -pub struct InstanceTemplateMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for InstanceTemplateMethods<'a, C, A> {} - -impl<'a, C, A> InstanceTemplateMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified instance template. If you delete an instance template that is being referenced from another instance group, the instance group will not be able to create or recreate virtual machine instances. Deleting an instance template is permanent and cannot be undone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `instanceTemplate` - The name of the instance template to delete. - pub fn delete(&self, project: &str, instance_template: &str) -> InstanceTemplateDeleteCall<'a, C, A> { - InstanceTemplateDeleteCall { - hub: self.hub, - _project: project.to_string(), - _instance_template: instance_template.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified instance template. Get a list of available instance templates by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `instanceTemplate` - The name of the instance template. - pub fn get(&self, project: &str, instance_template: &str) -> InstanceTemplateGetCall<'a, C, A> { - InstanceTemplateGetCall { - hub: self.hub, - _project: project.to_string(), - _instance_template: instance_template.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of instance templates that are contained within the specified project and zone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> InstanceTemplateListCall<'a, C, A> { - InstanceTemplateListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates an instance template in the specified project using the data that is included in the request. If you are creating a new template to update an existing instance group, your new instance template must use the same network or, if applicable, the same subnetwork as the original template. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: InstanceTemplate, project: &str) -> InstanceTemplateInsertCall<'a, C, A> { - InstanceTemplateInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *targetHttpProxy* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)` and `set_url_map(...)` -/// // to build up your call. -/// let rb = hub.target_http_proxies(); -/// # } -/// ``` -pub struct TargetHttpProxyMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for TargetHttpProxyMethods<'a, C, A> {} - -impl<'a, C, A> TargetHttpProxyMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified TargetHttpProxy resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `targetHttpProxy` - Name of the TargetHttpProxy resource to delete. - pub fn delete(&self, project: &str, target_http_proxy: &str) -> TargetHttpProxyDeleteCall<'a, C, A> { - TargetHttpProxyDeleteCall { - hub: self.hub, - _project: project.to_string(), - _target_http_proxy: target_http_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of TargetHttpProxy resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> TargetHttpProxyListCall<'a, C, A> { - TargetHttpProxyListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Changes the URL map for TargetHttpProxy. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `targetHttpProxy` - Name of the TargetHttpProxy to set a URL map for. - pub fn set_url_map(&self, request: UrlMapReference, project: &str, target_http_proxy: &str) -> TargetHttpProxySetUrlMapCall<'a, C, A> { - TargetHttpProxySetUrlMapCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _target_http_proxy: target_http_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified TargetHttpProxy resource. Get a list of available target HTTP proxies by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `targetHttpProxy` - Name of the TargetHttpProxy resource to return. - pub fn get(&self, project: &str, target_http_proxy: &str) -> TargetHttpProxyGetCall<'a, C, A> { - TargetHttpProxyGetCall { - hub: self.hub, - _project: project.to_string(), - _target_http_proxy: target_http_proxy.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a TargetHttpProxy resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: TargetHttpProxy, project: &str) -> TargetHttpProxyInsertCall<'a, C, A> { - TargetHttpProxyInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *sslCertificate* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.ssl_certificates(); -/// # } -/// ``` -pub struct SslCertificateMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for SslCertificateMethods<'a, C, A> {} - -impl<'a, C, A> SslCertificateMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified SslCertificate resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `sslCertificate` - Name of the SslCertificate resource to delete. - pub fn delete(&self, project: &str, ssl_certificate: &str) -> SslCertificateDeleteCall<'a, C, A> { - SslCertificateDeleteCall { - hub: self.hub, - _project: project.to_string(), - _ssl_certificate: ssl_certificate.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of SslCertificate resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> SslCertificateListCall<'a, C, A> { - SslCertificateListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a SslCertificate resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: SslCertificate, project: &str) -> SslCertificateInsertCall<'a, C, A> { - SslCertificateInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified SslCertificate resource. Get a list of available SSL certificates by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `sslCertificate` - Name of the SslCertificate resource to return. - pub fn get(&self, project: &str, ssl_certificate: &str) -> SslCertificateGetCall<'a, C, A> { - SslCertificateGetCall { - hub: self.hub, - _project: project.to_string(), - _ssl_certificate: ssl_certificate.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *zoneOperation* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.zone_operations(); -/// # } -/// ``` -pub struct ZoneOperationMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for ZoneOperationMethods<'a, C, A> {} - -impl<'a, C, A> ZoneOperationMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified zone-specific Operations resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone for this request. - /// * `operation` - Name of the Operations resource to delete. - pub fn delete(&self, project: &str, zone: &str, operation: &str) -> ZoneOperationDeleteCall<'a, C, A> { - ZoneOperationDeleteCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _operation: operation.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of Operation resources contained within the specified zone. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone for request. - pub fn list(&self, project: &str, zone: &str) -> ZoneOperationListCall<'a, C, A> { - ZoneOperationListCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the specified zone-specific Operations resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `zone` - Name of the zone for this request. - /// * `operation` - Name of the Operations resource to return. - pub fn get(&self, project: &str, zone: &str, operation: &str) -> ZoneOperationGetCall<'a, C, A> { - ZoneOperationGetCall { - hub: self.hub, - _project: project.to_string(), - _zone: zone.to_string(), - _operation: operation.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *route* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.routes(); -/// # } -/// ``` -pub struct RouteMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for RouteMethods<'a, C, A> {} - -impl<'a, C, A> RouteMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified Route resource. Get a list of available routes by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `route` - Name of the Route resource to return. - pub fn get(&self, project: &str, route: &str) -> RouteGetCall<'a, C, A> { - RouteGetCall { - hub: self.hub, - _project: project.to_string(), - _route: route.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a Route resource in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: Route, project: &str) -> RouteInsertCall<'a, C, A> { - RouteInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of Route resources available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> RouteListCall<'a, C, A> { - RouteListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified Route resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `route` - Name of the Route resource to delete. - pub fn delete(&self, project: &str, route: &str) -> RouteDeleteCall<'a, C, A> { - RouteDeleteCall { - hub: self.hub, - _project: project.to_string(), - _route: route.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *firewall* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` -/// // to build up your call. -/// let rb = hub.firewalls(); -/// # } -/// ``` -pub struct FirewallMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for FirewallMethods<'a, C, A> {} - -impl<'a, C, A> FirewallMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Updates the specified firewall rule with the data included in the request. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `firewall` - Name of the firewall rule to update. - pub fn patch(&self, request: Firewall, project: &str, firewall: &str) -> FirewallPatchCall<'a, C, A> { - FirewallPatchCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _firewall: firewall.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified firewall. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `firewall` - Name of the firewall rule to return. - pub fn get(&self, project: &str, firewall: &str) -> FirewallGetCall<'a, C, A> { - FirewallGetCall { - hub: self.hub, - _project: project.to_string(), - _firewall: firewall.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates the specified firewall rule with the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `firewall` - Name of the firewall rule to update. - pub fn update(&self, request: Firewall, project: &str, firewall: &str) -> FirewallUpdateCall<'a, C, A> { - FirewallUpdateCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _firewall: firewall.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a firewall rule in the specified project using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - pub fn insert(&self, request: Firewall, project: &str) -> FirewallInsertCall<'a, C, A> { - FirewallInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the list of firewall rules available to the specified project. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn list(&self, project: &str) -> FirewallListCall<'a, C, A> { - FirewallListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified firewall. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `firewall` - Name of the firewall rule to delete. - pub fn delete(&self, project: &str, firewall: &str) -> FirewallDeleteCall<'a, C, A> { - FirewallDeleteCall { - hub: self.hub, - _project: project.to_string(), - _firewall: firewall.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *vpnTunnel* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aggregated_list(...)`, `delete(...)`, `get(...)`, `insert(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.vpn_tunnels(); -/// # } -/// ``` -pub struct VpnTunnelMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for VpnTunnelMethods<'a, C, A> {} - -impl<'a, C, A> VpnTunnelMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Creates a VpnTunnel resource in the specified project and region using the data included in the request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - pub fn insert(&self, request: VpnTunnel, project: &str, region: &str) -> VpnTunnelInsertCall<'a, C, A> { - VpnTunnelInsertCall { - hub: self.hub, - _request: request, - _project: project.to_string(), - _region: region.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified VpnTunnel resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `vpnTunnel` - Name of the VpnTunnel resource to delete. - pub fn delete(&self, project: &str, region: &str, vpn_tunnel: &str) -> VpnTunnelDeleteCall<'a, C, A> { - VpnTunnelDeleteCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _vpn_tunnel: vpn_tunnel.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified VpnTunnel resource. Get a list of available VPN tunnels by making a list() request. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `vpnTunnel` - Name of the VpnTunnel resource to return. - pub fn get(&self, project: &str, region: &str, vpn_tunnel: &str) -> VpnTunnelGetCall<'a, C, A> { - VpnTunnelGetCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _vpn_tunnel: vpn_tunnel.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves an aggregated list of VPN tunnels. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> VpnTunnelAggregatedListCall<'a, C, A> { - VpnTunnelAggregatedListCall { - hub: self.hub, - _project: project.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of VpnTunnel resources contained in the specified project and region. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - pub fn list(&self, project: &str, region: &str) -> VpnTunnelListCall<'a, C, A> { - VpnTunnelListCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *regionOperation* resources. -/// It is not used directly, but through the `Compute` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_compute1 as compute1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use compute1::Compute; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Compute::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.region_operations(); -/// # } -/// ``` -pub struct RegionOperationMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, -} - -impl<'a, C, A> MethodsBuilder for RegionOperationMethods<'a, C, A> {} - -impl<'a, C, A> RegionOperationMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of Operation resources contained within the specified region. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - pub fn list(&self, project: &str, region: &str) -> RegionOperationListCall<'a, C, A> { - RegionOperationListCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _filter: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes the specified region-specific Operations resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `operation` - Name of the Operations resource to delete. - pub fn delete(&self, project: &str, region: &str, operation: &str) -> RegionOperationDeleteCall<'a, C, A> { - RegionOperationDeleteCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _operation: operation.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the specified region-specific Operations resource. - /// - /// # Arguments - /// - /// * `project` - Project ID for this request. - /// * `region` - Name of the region for this request. - /// * `operation` - Name of the Operations resource to return. - pub fn get(&self, project: &str, region: &str, operation: &str) -> RegionOperationGetCall<'a, C, A> { - RegionOperationGetCall { - hub: self.hub, - _project: project.to_string(), - _region: region.to_string(), - _operation: operation.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - - - -// ################### -// CallBuilders ### -// ################# - -/// Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots. -/// -/// A builder for the *delete* method supported by a *disk* resource. -/// It is not used directly, but through a `DiskMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.disks().delete("project", "zone", "disk") -/// .doit(); -/// # } -/// ``` -pub struct DiskDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _disk: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DiskDeleteCall<'a, C, A> {} - -impl<'a, C, A> DiskDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.disks.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("disk", self._disk.to_string())); - for &field in ["alt", "project", "zone", "disk"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks/{disk}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{disk}", "disk")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["disk", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> DiskDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> DiskDeleteCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the persistent disk to delete. - /// - /// Sets the *disk* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn disk(mut self, new_value: &str) -> DiskDeleteCall<'a, C, A> { - self._disk = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DiskDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DiskDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DiskDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of persistent disks. -/// -/// A builder for the *aggregatedList* method supported by a *disk* resource. -/// It is not used directly, but through a `DiskMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.disks().aggregated_list("project") -/// .page_token("nonumy") -/// .max_results(82) -/// .filter("gubergren") -/// .doit(); -/// # } -/// ``` -pub struct DiskAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DiskAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> DiskAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, DiskAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.disks.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/disks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> DiskAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> DiskAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> DiskAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> DiskAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DiskAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DiskAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DiskAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns a specified persistent disk. Get a list of available persistent disks by making a list() request. -/// -/// A builder for the *get* method supported by a *disk* resource. -/// It is not used directly, but through a `DiskMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.disks().get("project", "zone", "disk") -/// .doit(); -/// # } -/// ``` -pub struct DiskGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _disk: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DiskGetCall<'a, C, A> {} - -impl<'a, C, A> DiskGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Disk)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.disks.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("disk", self._disk.to_string())); - for &field in ["alt", "project", "zone", "disk"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks/{disk}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{disk}", "disk")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["disk", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> DiskGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> DiskGetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the persistent disk to return. - /// - /// Sets the *disk* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn disk(mut self, new_value: &str) -> DiskGetCall<'a, C, A> { - self._disk = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DiskGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DiskGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DiskGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of persistent disks contained within the specified zone. -/// -/// A builder for the *list* method supported by a *disk* resource. -/// It is not used directly, but through a `DiskMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.disks().list("project", "zone") -/// .page_token("justo") -/// .max_results(67) -/// .filter("et") -/// .doit(); -/// # } -/// ``` -pub struct DiskListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DiskListCall<'a, C, A> {} - -impl<'a, C, A> DiskListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, DiskList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.disks.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> DiskListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> DiskListCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> DiskListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> DiskListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> DiskListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DiskListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DiskListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DiskListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Resizes the specified persistent disk. -/// -/// A builder for the *resize* method supported by a *disk* resource. -/// It is not used directly, but through a `DiskMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::DisksResizeRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = DisksResizeRequest::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.disks().resize(req, "project", "zone", "disk") -/// .doit(); -/// # } -/// ``` -pub struct DiskResizeCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: DisksResizeRequest, - _project: String, - _zone: String, - _disk: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DiskResizeCall<'a, C, A> {} - -impl<'a, C, A> DiskResizeCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.disks.resize", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("disk", self._disk.to_string())); - for &field in ["alt", "project", "zone", "disk"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks/{disk}/resize".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{disk}", "disk")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["disk", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: DisksResizeRequest) -> DiskResizeCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> DiskResizeCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> DiskResizeCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the persistent disk. - /// - /// Sets the *disk* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn disk(mut self, new_value: &str) -> DiskResizeCall<'a, C, A> { - self._disk = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DiskResizeCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DiskResizeCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DiskResizeCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a persistent disk in the specified project using the data in the request. You can create a disk with a sourceImage, a sourceSnapshot, or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property. -/// -/// A builder for the *insert* method supported by a *disk* resource. -/// It is not used directly, but through a `DiskMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Disk; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Disk::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.disks().insert(req, "project", "zone") -/// .source_image("aliquyam") -/// .doit(); -/// # } -/// ``` -pub struct DiskInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Disk, - _project: String, - _zone: String, - _source_image: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DiskInsertCall<'a, C, A> {} - -impl<'a, C, A> DiskInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.disks.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._source_image { - params.push(("sourceImage", value.to_string())); - } - for &field in ["alt", "project", "zone", "sourceImage"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Disk) -> DiskInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> DiskInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> DiskInsertCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Optional. Source image to restore onto a disk. - /// - /// Sets the *source image* query property to the given value. - pub fn source_image(mut self, new_value: &str) -> DiskInsertCall<'a, C, A> { - self._source_image = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DiskInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DiskInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DiskInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a snapshot of a specified persistent disk. -/// -/// A builder for the *createSnapshot* method supported by a *disk* resource. -/// It is not used directly, but through a `DiskMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Snapshot; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Snapshot::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.disks().create_snapshot(req, "project", "zone", "disk") -/// .doit(); -/// # } -/// ``` -pub struct DiskCreateSnapshotCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Snapshot, - _project: String, - _zone: String, - _disk: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DiskCreateSnapshotCall<'a, C, A> {} - -impl<'a, C, A> DiskCreateSnapshotCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.disks.createSnapshot", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("disk", self._disk.to_string())); - for &field in ["alt", "project", "zone", "disk"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks/{disk}/createSnapshot".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{disk}", "disk")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["disk", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Snapshot) -> DiskCreateSnapshotCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> DiskCreateSnapshotCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> DiskCreateSnapshotCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the persistent disk to snapshot. - /// - /// Sets the *disk* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn disk(mut self, new_value: &str) -> DiskCreateSnapshotCall<'a, C, A> { - self._disk = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DiskCreateSnapshotCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DiskCreateSnapshotCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DiskCreateSnapshotCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of TargetSslProxy resources available to the specified project. -/// -/// A builder for the *list* method supported by a *targetSslProxy* resource. -/// It is not used directly, but through a `TargetSslProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_ssl_proxies().list("project") -/// .page_token("sadipscing") -/// .max_results(53) -/// .filter("eirmod") -/// .doit(); -/// # } -/// ``` -pub struct TargetSslProxyListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetSslProxyListCall<'a, C, A> {} - -impl<'a, C, A> TargetSslProxyListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetSslProxyList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetSslProxies.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetSslProxyListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> TargetSslProxyListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> TargetSslProxyListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> TargetSslProxyListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetSslProxyListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetSslProxyListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetSslProxyListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Changes SslCertificates for TargetSslProxy. -/// -/// A builder for the *setSslCertificates* method supported by a *targetSslProxy* resource. -/// It is not used directly, but through a `TargetSslProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetSslProxiesSetSslCertificatesRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetSslProxiesSetSslCertificatesRequest::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.target_ssl_proxies().set_ssl_certificates(req, "project", "targetSslProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetSslProxySetSslCertificateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetSslProxiesSetSslCertificatesRequest, - _project: String, - _target_ssl_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetSslProxySetSslCertificateCall<'a, C, A> {} - -impl<'a, C, A> TargetSslProxySetSslCertificateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetSslProxies.setSslCertificates", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetSslProxy", self._target_ssl_proxy.to_string())); - for &field in ["alt", "project", "targetSslProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies/{targetSslProxy}/setSslCertificates".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetSslProxy}", "targetSslProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetSslProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetSslProxiesSetSslCertificatesRequest) -> TargetSslProxySetSslCertificateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetSslProxySetSslCertificateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetSslProxy resource whose SslCertificate resource is to be set. - /// - /// Sets the *target ssl proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_ssl_proxy(mut self, new_value: &str) -> TargetSslProxySetSslCertificateCall<'a, C, A> { - self._target_ssl_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetSslProxySetSslCertificateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetSslProxySetSslCertificateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetSslProxySetSslCertificateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Changes the BackendService for TargetSslProxy. -/// -/// A builder for the *setBackendService* method supported by a *targetSslProxy* resource. -/// It is not used directly, but through a `TargetSslProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetSslProxiesSetBackendServiceRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetSslProxiesSetBackendServiceRequest::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.target_ssl_proxies().set_backend_service(req, "project", "targetSslProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetSslProxySetBackendServiceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetSslProxiesSetBackendServiceRequest, - _project: String, - _target_ssl_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetSslProxySetBackendServiceCall<'a, C, A> {} - -impl<'a, C, A> TargetSslProxySetBackendServiceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetSslProxies.setBackendService", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetSslProxy", self._target_ssl_proxy.to_string())); - for &field in ["alt", "project", "targetSslProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies/{targetSslProxy}/setBackendService".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetSslProxy}", "targetSslProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetSslProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetSslProxiesSetBackendServiceRequest) -> TargetSslProxySetBackendServiceCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetSslProxySetBackendServiceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetSslProxy resource whose BackendService resource is to be set. - /// - /// Sets the *target ssl proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_ssl_proxy(mut self, new_value: &str) -> TargetSslProxySetBackendServiceCall<'a, C, A> { - self._target_ssl_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetSslProxySetBackendServiceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetSslProxySetBackendServiceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetSslProxySetBackendServiceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified TargetSslProxy resource. -/// -/// A builder for the *delete* method supported by a *targetSslProxy* resource. -/// It is not used directly, but through a `TargetSslProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_ssl_proxies().delete("project", "targetSslProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetSslProxyDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _target_ssl_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetSslProxyDeleteCall<'a, C, A> {} - -impl<'a, C, A> TargetSslProxyDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetSslProxies.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetSslProxy", self._target_ssl_proxy.to_string())); - for &field in ["alt", "project", "targetSslProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies/{targetSslProxy}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetSslProxy}", "targetSslProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetSslProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetSslProxyDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetSslProxy resource to delete. - /// - /// Sets the *target ssl proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_ssl_proxy(mut self, new_value: &str) -> TargetSslProxyDeleteCall<'a, C, A> { - self._target_ssl_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetSslProxyDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetSslProxyDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetSslProxyDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified TargetSslProxy resource. Get a list of available target SSL proxies by making a list() request. -/// -/// A builder for the *get* method supported by a *targetSslProxy* resource. -/// It is not used directly, but through a `TargetSslProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_ssl_proxies().get("project", "targetSslProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetSslProxyGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _target_ssl_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetSslProxyGetCall<'a, C, A> {} - -impl<'a, C, A> TargetSslProxyGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetSslProxy)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetSslProxies.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetSslProxy", self._target_ssl_proxy.to_string())); - for &field in ["alt", "project", "targetSslProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies/{targetSslProxy}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetSslProxy}", "targetSslProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetSslProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetSslProxyGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetSslProxy resource to return. - /// - /// Sets the *target ssl proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_ssl_proxy(mut self, new_value: &str) -> TargetSslProxyGetCall<'a, C, A> { - self._target_ssl_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetSslProxyGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetSslProxyGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetSslProxyGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Changes the ProxyHeaderType for TargetSslProxy. -/// -/// A builder for the *setProxyHeader* method supported by a *targetSslProxy* resource. -/// It is not used directly, but through a `TargetSslProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetSslProxiesSetProxyHeaderRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetSslProxiesSetProxyHeaderRequest::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.target_ssl_proxies().set_proxy_header(req, "project", "targetSslProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetSslProxySetProxyHeaderCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetSslProxiesSetProxyHeaderRequest, - _project: String, - _target_ssl_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetSslProxySetProxyHeaderCall<'a, C, A> {} - -impl<'a, C, A> TargetSslProxySetProxyHeaderCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetSslProxies.setProxyHeader", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetSslProxy", self._target_ssl_proxy.to_string())); - for &field in ["alt", "project", "targetSslProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies/{targetSslProxy}/setProxyHeader".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetSslProxy}", "targetSslProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetSslProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetSslProxiesSetProxyHeaderRequest) -> TargetSslProxySetProxyHeaderCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetSslProxySetProxyHeaderCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetSslProxy resource whose ProxyHeader is to be set. - /// - /// Sets the *target ssl proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_ssl_proxy(mut self, new_value: &str) -> TargetSslProxySetProxyHeaderCall<'a, C, A> { - self._target_ssl_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetSslProxySetProxyHeaderCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetSslProxySetProxyHeaderCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetSslProxySetProxyHeaderCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a TargetSslProxy resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *targetSslProxy* resource. -/// It is not used directly, but through a `TargetSslProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetSslProxy; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetSslProxy::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.target_ssl_proxies().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct TargetSslProxyInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetSslProxy, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetSslProxyInsertCall<'a, C, A> {} - -impl<'a, C, A> TargetSslProxyInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetSslProxies.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetSslProxy) -> TargetSslProxyInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetSslProxyInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetSslProxyInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetSslProxyInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetSslProxyInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a UrlMap resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *urlMap* resource. -/// It is not used directly, but through a `UrlMapMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::UrlMap; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = UrlMap::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.url_maps().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct UrlMapInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: UrlMap, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UrlMapInsertCall<'a, C, A> {} - -impl<'a, C, A> UrlMapInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.urlMaps.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: UrlMap) -> UrlMapInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> UrlMapInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UrlMapInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> UrlMapInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> UrlMapInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified UrlMap resource. Get a list of available URL maps by making a list() request. -/// -/// A builder for the *get* method supported by a *urlMap* resource. -/// It is not used directly, but through a `UrlMapMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.url_maps().get("project", "urlMap") -/// .doit(); -/// # } -/// ``` -pub struct UrlMapGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _url_map: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UrlMapGetCall<'a, C, A> {} - -impl<'a, C, A> UrlMapGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, UrlMap)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.urlMaps.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("urlMap", self._url_map.to_string())); - for &field in ["alt", "project", "urlMap"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps/{urlMap}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{urlMap}", "urlMap")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["urlMap", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> UrlMapGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the UrlMap resource to return. - /// - /// Sets the *url map* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn url_map(mut self, new_value: &str) -> UrlMapGetCall<'a, C, A> { - self._url_map = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UrlMapGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> UrlMapGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> UrlMapGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap. -/// -/// A builder for the *validate* method supported by a *urlMap* resource. -/// It is not used directly, but through a `UrlMapMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::UrlMapsValidateRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = UrlMapsValidateRequest::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.url_maps().validate(req, "project", "urlMap") -/// .doit(); -/// # } -/// ``` -pub struct UrlMapValidateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: UrlMapsValidateRequest, - _project: String, - _url_map: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UrlMapValidateCall<'a, C, A> {} - -impl<'a, C, A> UrlMapValidateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, UrlMapsValidateResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.urlMaps.validate", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("urlMap", self._url_map.to_string())); - for &field in ["alt", "project", "urlMap"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps/{urlMap}/validate".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{urlMap}", "urlMap")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["urlMap", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: UrlMapsValidateRequest) -> UrlMapValidateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> UrlMapValidateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the UrlMap resource to be validated as. - /// - /// Sets the *url map* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn url_map(mut self, new_value: &str) -> UrlMapValidateCall<'a, C, A> { - self._url_map = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UrlMapValidateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> UrlMapValidateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> UrlMapValidateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of UrlMap resources available to the specified project. -/// -/// A builder for the *list* method supported by a *urlMap* resource. -/// It is not used directly, but through a `UrlMapMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.url_maps().list("project") -/// .page_token("amet") -/// .max_results(78) -/// .filter("consetetur") -/// .doit(); -/// # } -/// ``` -pub struct UrlMapListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UrlMapListCall<'a, C, A> {} - -impl<'a, C, A> UrlMapListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, UrlMapList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.urlMaps.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> UrlMapListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> UrlMapListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> UrlMapListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> UrlMapListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UrlMapListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> UrlMapListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> UrlMapListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap. -/// -/// A builder for the *invalidateCache* method supported by a *urlMap* resource. -/// It is not used directly, but through a `UrlMapMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::CacheInvalidationRule; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = CacheInvalidationRule::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.url_maps().invalidate_cache(req, "project", "urlMap") -/// .doit(); -/// # } -/// ``` -pub struct UrlMapInvalidateCacheCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: CacheInvalidationRule, - _project: String, - _url_map: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UrlMapInvalidateCacheCall<'a, C, A> {} - -impl<'a, C, A> UrlMapInvalidateCacheCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.urlMaps.invalidateCache", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("urlMap", self._url_map.to_string())); - for &field in ["alt", "project", "urlMap"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps/{urlMap}/invalidateCache".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{urlMap}", "urlMap")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["urlMap", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: CacheInvalidationRule) -> UrlMapInvalidateCacheCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> UrlMapInvalidateCacheCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the UrlMap scoping this request. - /// - /// Sets the *url map* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn url_map(mut self, new_value: &str) -> UrlMapInvalidateCacheCall<'a, C, A> { - self._url_map = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UrlMapInvalidateCacheCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> UrlMapInvalidateCacheCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> UrlMapInvalidateCacheCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates the entire content of the UrlMap resource. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *urlMap* resource. -/// It is not used directly, but through a `UrlMapMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::UrlMap; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = UrlMap::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.url_maps().patch(req, "project", "urlMap") -/// .doit(); -/// # } -/// ``` -pub struct UrlMapPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: UrlMap, - _project: String, - _url_map: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UrlMapPatchCall<'a, C, A> {} - -impl<'a, C, A> UrlMapPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.urlMaps.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("urlMap", self._url_map.to_string())); - for &field in ["alt", "project", "urlMap"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps/{urlMap}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{urlMap}", "urlMap")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["urlMap", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: UrlMap) -> UrlMapPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> UrlMapPatchCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the UrlMap resource to update. - /// - /// Sets the *url map* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn url_map(mut self, new_value: &str) -> UrlMapPatchCall<'a, C, A> { - self._url_map = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UrlMapPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> UrlMapPatchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> UrlMapPatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates the entire content of the UrlMap resource. -/// -/// A builder for the *update* method supported by a *urlMap* resource. -/// It is not used directly, but through a `UrlMapMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::UrlMap; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = UrlMap::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.url_maps().update(req, "project", "urlMap") -/// .doit(); -/// # } -/// ``` -pub struct UrlMapUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: UrlMap, - _project: String, - _url_map: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UrlMapUpdateCall<'a, C, A> {} - -impl<'a, C, A> UrlMapUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.urlMaps.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("urlMap", self._url_map.to_string())); - for &field in ["alt", "project", "urlMap"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps/{urlMap}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{urlMap}", "urlMap")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["urlMap", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: UrlMap) -> UrlMapUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> UrlMapUpdateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the UrlMap resource to update. - /// - /// Sets the *url map* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn url_map(mut self, new_value: &str) -> UrlMapUpdateCall<'a, C, A> { - self._url_map = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UrlMapUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> UrlMapUpdateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> UrlMapUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified UrlMap resource. -/// -/// A builder for the *delete* method supported by a *urlMap* resource. -/// It is not used directly, but through a `UrlMapMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.url_maps().delete("project", "urlMap") -/// .doit(); -/// # } -/// ``` -pub struct UrlMapDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _url_map: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UrlMapDeleteCall<'a, C, A> {} - -impl<'a, C, A> UrlMapDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.urlMaps.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("urlMap", self._url_map.to_string())); - for &field in ["alt", "project", "urlMap"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps/{urlMap}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{urlMap}", "urlMap")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["urlMap", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> UrlMapDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the UrlMap resource to delete. - /// - /// Sets the *url map* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn url_map(mut self, new_value: &str) -> UrlMapDeleteCall<'a, C, A> { - self._url_map = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UrlMapDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> UrlMapDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> UrlMapDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates an address resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *globalAddresse* resource. -/// It is not used directly, but through a `GlobalAddresseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Address; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Address::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.global_addresses().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct GlobalAddresseInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Address, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalAddresseInsertCall<'a, C, A> {} - -impl<'a, C, A> GlobalAddresseInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalAddresses.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/addresses".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Address) -> GlobalAddresseInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalAddresseInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalAddresseInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalAddresseInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalAddresseInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of global addresses. -/// -/// A builder for the *list* method supported by a *globalAddresse* resource. -/// It is not used directly, but through a `GlobalAddresseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.global_addresses().list("project") -/// .page_token("Lorem") -/// .max_results(90) -/// .filter("justo") -/// .doit(); -/// # } -/// ``` -pub struct GlobalAddresseListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalAddresseListCall<'a, C, A> {} - -impl<'a, C, A> GlobalAddresseListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, AddressList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalAddresses.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/addresses".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalAddresseListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> GlobalAddresseListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> GlobalAddresseListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> GlobalAddresseListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalAddresseListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalAddresseListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalAddresseListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified address resource. Get a list of available addresses by making a list() request. -/// -/// A builder for the *get* method supported by a *globalAddresse* resource. -/// It is not used directly, but through a `GlobalAddresseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.global_addresses().get("project", "address") -/// .doit(); -/// # } -/// ``` -pub struct GlobalAddresseGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _address: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalAddresseGetCall<'a, C, A> {} - -impl<'a, C, A> GlobalAddresseGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Address)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalAddresses.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("address", self._address.to_string())); - for &field in ["alt", "project", "address"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/addresses/{address}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{address}", "address")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["address", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalAddresseGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the address resource to return. - /// - /// Sets the *address* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn address(mut self, new_value: &str) -> GlobalAddresseGetCall<'a, C, A> { - self._address = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalAddresseGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalAddresseGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalAddresseGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified address resource. -/// -/// A builder for the *delete* method supported by a *globalAddresse* resource. -/// It is not used directly, but through a `GlobalAddresseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.global_addresses().delete("project", "address") -/// .doit(); -/// # } -/// ``` -pub struct GlobalAddresseDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _address: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalAddresseDeleteCall<'a, C, A> {} - -impl<'a, C, A> GlobalAddresseDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalAddresses.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("address", self._address.to_string())); - for &field in ["alt", "project", "address"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/addresses/{address}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{address}", "address")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["address", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalAddresseDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the address resource to delete. - /// - /// Sets the *address* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn address(mut self, new_value: &str) -> GlobalAddresseDeleteCall<'a, C, A> { - self._address = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalAddresseDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalAddresseDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalAddresseDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified Snapshot resource. Get a list of available snapshots by making a list() request. -/// -/// A builder for the *get* method supported by a *snapshot* resource. -/// It is not used directly, but through a `SnapshotMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.snapshots().get("project", "snapshot") -/// .doit(); -/// # } -/// ``` -pub struct SnapshotGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _snapshot: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SnapshotGetCall<'a, C, A> {} - -impl<'a, C, A> SnapshotGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Snapshot)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.snapshots.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("snapshot", self._snapshot.to_string())); - for &field in ["alt", "project", "snapshot"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/snapshots/{snapshot}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{snapshot}", "snapshot")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["snapshot", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SnapshotGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the Snapshot resource to return. - /// - /// Sets the *snapshot* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn snapshot(mut self, new_value: &str) -> SnapshotGetCall<'a, C, A> { - self._snapshot = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SnapshotGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SnapshotGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SnapshotGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of Snapshot resources contained within the specified project. -/// -/// A builder for the *list* method supported by a *snapshot* resource. -/// It is not used directly, but through a `SnapshotMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.snapshots().list("project") -/// .page_token("sadipscing") -/// .max_results(13) -/// .filter("consetetur") -/// .doit(); -/// # } -/// ``` -pub struct SnapshotListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SnapshotListCall<'a, C, A> {} - -impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SnapshotList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.snapshots.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/snapshots".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SnapshotListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> SnapshotListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> SnapshotListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> SnapshotListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SnapshotListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SnapshotListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SnapshotListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot. -/// -/// For more information, see Deleting snaphots. -/// -/// A builder for the *delete* method supported by a *snapshot* resource. -/// It is not used directly, but through a `SnapshotMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.snapshots().delete("project", "snapshot") -/// .doit(); -/// # } -/// ``` -pub struct SnapshotDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _snapshot: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SnapshotDeleteCall<'a, C, A> {} - -impl<'a, C, A> SnapshotDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.snapshots.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("snapshot", self._snapshot.to_string())); - for &field in ["alt", "project", "snapshot"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/snapshots/{snapshot}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{snapshot}", "snapshot")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["snapshot", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SnapshotDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the Snapshot resource to delete. - /// - /// Sets the *snapshot* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn snapshot(mut self, new_value: &str) -> SnapshotDeleteCall<'a, C, A> { - self._snapshot = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SnapshotDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SnapshotDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SnapshotDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified disk type. Get a list of available disk types by making a list() request. -/// -/// A builder for the *get* method supported by a *diskType* resource. -/// It is not used directly, but through a `DiskTypeMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.disk_types().get("project", "zone", "diskType") -/// .doit(); -/// # } -/// ``` -pub struct DiskTypeGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _disk_type: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DiskTypeGetCall<'a, C, A> {} - -impl<'a, C, A> DiskTypeGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, DiskType)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.diskTypes.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("diskType", self._disk_type.to_string())); - for &field in ["alt", "project", "zone", "diskType"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/diskTypes/{diskType}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{diskType}", "diskType")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["diskType", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> DiskTypeGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> DiskTypeGetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the disk type to return. - /// - /// Sets the *disk type* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn disk_type(mut self, new_value: &str) -> DiskTypeGetCall<'a, C, A> { - self._disk_type = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DiskTypeGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DiskTypeGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DiskTypeGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of disk types. -/// -/// A builder for the *aggregatedList* method supported by a *diskType* resource. -/// It is not used directly, but through a `DiskTypeMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.disk_types().aggregated_list("project") -/// .page_token("consetetur") -/// .max_results(43) -/// .filter("nonumy") -/// .doit(); -/// # } -/// ``` -pub struct DiskTypeAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DiskTypeAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> DiskTypeAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, DiskTypeAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.diskTypes.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/diskTypes".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> DiskTypeAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> DiskTypeAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> DiskTypeAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> DiskTypeAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DiskTypeAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DiskTypeAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DiskTypeAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of disk types available to the specified project. -/// -/// A builder for the *list* method supported by a *diskType* resource. -/// It is not used directly, but through a `DiskTypeMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.disk_types().list("project", "zone") -/// .page_token("takimata") -/// .max_results(74) -/// .filter("labore") -/// .doit(); -/// # } -/// ``` -pub struct DiskTypeListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DiskTypeListCall<'a, C, A> {} - -impl<'a, C, A> DiskTypeListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, DiskTypeList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.diskTypes.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/diskTypes".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> DiskTypeListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> DiskTypeListCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> DiskTypeListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> DiskTypeListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> DiskTypeListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DiskTypeListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DiskTypeListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DiskTypeListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified Zone resource. Get a list of available zones by making a list() request. -/// -/// A builder for the *get* method supported by a *zone* resource. -/// It is not used directly, but through a `ZoneMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.zones().get("project", "zone") -/// .doit(); -/// # } -/// ``` -pub struct ZoneGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ZoneGetCall<'a, C, A> {} - -impl<'a, C, A> ZoneGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Zone)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.zones.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - for &field in ["alt", "project", "zone"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ZoneGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone resource to return. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> ZoneGetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ZoneGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ZoneGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ZoneGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of Zone resources available to the specified project. -/// -/// A builder for the *list* method supported by a *zone* resource. -/// It is not used directly, but through a `ZoneMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.zones().list("project") -/// .page_token("rebum.") -/// .max_results(68) -/// .filter("nonumy") -/// .doit(); -/// # } -/// ``` -pub struct ZoneListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ZoneListCall<'a, C, A> {} - -impl<'a, C, A> ZoneListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ZoneList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.zones.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ZoneListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ZoneListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> ZoneListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> ZoneListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ZoneListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ZoneListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ZoneListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Changes the machine type for a stopped instance to the machine type specified in the request. -/// -/// A builder for the *setMachineType* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstancesSetMachineTypeRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstancesSetMachineTypeRequest::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.instances().set_machine_type(req, "project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceSetMachineTypeCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstancesSetMachineTypeRequest, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceSetMachineTypeCall<'a, C, A> {} - -impl<'a, C, A> InstanceSetMachineTypeCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.setMachineType", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setMachineType".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstancesSetMachineTypeRequest) -> InstanceSetMachineTypeCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceSetMachineTypeCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceSetMachineTypeCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the instance scoping this request. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceSetMachineTypeCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceSetMachineTypeCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceSetMachineTypeCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceSetMachineTypeCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Sets an instance's scheduling options. -/// -/// A builder for the *setScheduling* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Scheduling; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Scheduling::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.instances().set_scheduling(req, "project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceSetSchedulingCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Scheduling, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceSetSchedulingCall<'a, C, A> {} - -impl<'a, C, A> InstanceSetSchedulingCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.setScheduling", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setScheduling".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Scheduling) -> InstanceSetSchedulingCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceSetSchedulingCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceSetSchedulingCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Instance name. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceSetSchedulingCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceSetSchedulingCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceSetSchedulingCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceSetSchedulingCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified Instance resource. For more information, see Stopping or Deleting an Instance. -/// -/// A builder for the *delete* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().delete("project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceDeleteCall<'a, C, A> {} - -impl<'a, C, A> InstanceDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceDeleteCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the instance resource to delete. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceDeleteCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified instance's serial port output. -/// -/// A builder for the *getSerialPortOutput* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().get_serial_port_output("project", "zone", "instance") -/// .port(-59) -/// .doit(); -/// # } -/// ``` -pub struct InstanceGetSerialPortOutputCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance: String, - _port: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGetSerialPortOutputCall<'a, C, A> {} - -impl<'a, C, A> InstanceGetSerialPortOutputCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SerialPortOutput)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.getSerialPortOutput", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - if let Some(value) = self._port { - params.push(("port", value.to_string())); - } - for &field in ["alt", "project", "zone", "instance", "port"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/serialPort".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGetSerialPortOutputCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGetSerialPortOutputCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the instance scoping this request. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceGetSerialPortOutputCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// Specifies which COM or serial port to retrieve data from. - /// - /// Sets the *port* query property to the given value. - pub fn port(mut self, new_value: i32) -> InstanceGetSerialPortOutputCall<'a, C, A> { - self._port = Some(new_value); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGetSerialPortOutputCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGetSerialPortOutputCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGetSerialPortOutputCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Sets the auto-delete flag for a disk attached to an instance. -/// -/// A builder for the *setDiskAutoDelete* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().set_disk_auto_delete("project", "zone", "instance", false, "deviceName") -/// .doit(); -/// # } -/// ``` -pub struct InstanceSetDiskAutoDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance: String, - _auto_delete: bool, - _device_name: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceSetDiskAutoDeleteCall<'a, C, A> {} - -impl<'a, C, A> InstanceSetDiskAutoDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.setDiskAutoDelete", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - params.push(("autoDelete", self._auto_delete.to_string())); - params.push(("deviceName", self._device_name.to_string())); - for &field in ["alt", "project", "zone", "instance", "autoDelete", "deviceName"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setDiskAutoDelete".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceSetDiskAutoDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceSetDiskAutoDeleteCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The instance name. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceSetDiskAutoDeleteCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// Whether to auto-delete the disk when the instance is deleted. - /// - /// Sets the *auto delete* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn auto_delete(mut self, new_value: bool) -> InstanceSetDiskAutoDeleteCall<'a, C, A> { - self._auto_delete = new_value; - self - } - /// The device name of the disk to modify. - /// - /// Sets the *device name* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn device_name(mut self, new_value: &str) -> InstanceSetDiskAutoDeleteCall<'a, C, A> { - self._device_name = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceSetDiskAutoDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceSetDiskAutoDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceSetDiskAutoDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Adds an access config to an instance's network interface. -/// -/// A builder for the *addAccessConfig* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::AccessConfig; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = AccessConfig::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.instances().add_access_config(req, "project", "zone", "instance", "networkInterface") -/// .doit(); -/// # } -/// ``` -pub struct InstanceAddAccessConfigCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: AccessConfig, - _project: String, - _zone: String, - _instance: String, - _network_interface: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceAddAccessConfigCall<'a, C, A> {} - -impl<'a, C, A> InstanceAddAccessConfigCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.addAccessConfig", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - params.push(("networkInterface", self._network_interface.to_string())); - for &field in ["alt", "project", "zone", "instance", "networkInterface"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/addAccessConfig".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: AccessConfig) -> InstanceAddAccessConfigCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceAddAccessConfigCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceAddAccessConfigCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The instance name for this request. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceAddAccessConfigCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The name of the network interface to add to this instance. - /// - /// Sets the *network interface* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn network_interface(mut self, new_value: &str) -> InstanceAddAccessConfigCall<'a, C, A> { - self._network_interface = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceAddAccessConfigCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceAddAccessConfigCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceAddAccessConfigCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Sets metadata for the specified instance to the data included in the request. -/// -/// A builder for the *setMetadata* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Metadata; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Metadata::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.instances().set_metadata(req, "project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceSetMetadataCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Metadata, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceSetMetadataCall<'a, C, A> {} - -impl<'a, C, A> InstanceSetMetadataCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.setMetadata", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setMetadata".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Metadata) -> InstanceSetMetadataCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceSetMetadataCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceSetMetadataCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the instance scoping this request. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceSetMetadataCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceSetMetadataCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceSetMetadataCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceSetMetadataCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Starts an instance that was stopped using the using the instances().stop method. For more information, see Restart an instance. -/// -/// A builder for the *start* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().start("project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceStartCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceStartCall<'a, C, A> {} - -impl<'a, C, A> InstanceStartCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.start", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/start".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceStartCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceStartCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the instance resource to start. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceStartCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceStartCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceStartCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceStartCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified Instance resource. Get a list of available instances by making a list() request. -/// -/// A builder for the *get* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().get("project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGetCall<'a, C, A> {} - -impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Instance)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the instance resource to return. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceGetCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Sets tags for the specified instance to the data included in the request. -/// -/// A builder for the *setTags* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Tags; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Tags::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.instances().set_tags(req, "project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceSetTagCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Tags, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceSetTagCall<'a, C, A> {} - -impl<'a, C, A> InstanceSetTagCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.setTags", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setTags".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Tags) -> InstanceSetTagCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceSetTagCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceSetTagCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the instance scoping this request. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceSetTagCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceSetTagCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceSetTagCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceSetTagCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Detaches a disk from an instance. -/// -/// A builder for the *detachDisk* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().detach_disk("project", "zone", "instance", "deviceName") -/// .doit(); -/// # } -/// ``` -pub struct InstanceDetachDiskCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance: String, - _device_name: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceDetachDiskCall<'a, C, A> {} - -impl<'a, C, A> InstanceDetachDiskCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.detachDisk", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - params.push(("deviceName", self._device_name.to_string())); - for &field in ["alt", "project", "zone", "instance", "deviceName"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/detachDisk".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceDetachDiskCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceDetachDiskCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Instance name. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceDetachDiskCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// Disk device name to detach. - /// - /// Sets the *device name* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn device_name(mut self, new_value: &str) -> InstanceDetachDiskCall<'a, C, A> { - self._device_name = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceDetachDiskCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceDetachDiskCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceDetachDiskCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur per-minute, virtual machine usage charges while they are stopped, but any resources that the virtual machine is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance. -/// -/// A builder for the *stop* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().stop("project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceStopCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceStopCall<'a, C, A> {} - -impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.stop", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/stop".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceStopCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceStopCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the instance resource to stop. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceStopCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceStopCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceStopCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceStopCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates an instance resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Instance; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Instance::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.instances().insert(req, "project", "zone") -/// .doit(); -/// # } -/// ``` -pub struct InstanceInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Instance, - _project: String, - _zone: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceInsertCall<'a, C, A> {} - -impl<'a, C, A> InstanceInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - for &field in ["alt", "project", "zone"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Instance) -> InstanceInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceInsertCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Performs a hard reset on the instance. -/// -/// A builder for the *reset* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().reset("project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceResetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceResetCall<'a, C, A> {} - -impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.reset", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/reset".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceResetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceResetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the instance scoping this request. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceResetCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceResetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceResetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceResetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes an access config from an instance's network interface. -/// -/// A builder for the *deleteAccessConfig* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().delete_access_config("project", "zone", "instance", "accessConfig", "networkInterface") -/// .doit(); -/// # } -/// ``` -pub struct InstanceDeleteAccessConfigCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance: String, - _access_config: String, - _network_interface: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceDeleteAccessConfigCall<'a, C, A> {} - -impl<'a, C, A> InstanceDeleteAccessConfigCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.deleteAccessConfig", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - params.push(("accessConfig", self._access_config.to_string())); - params.push(("networkInterface", self._network_interface.to_string())); - for &field in ["alt", "project", "zone", "instance", "accessConfig", "networkInterface"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/deleteAccessConfig".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceDeleteAccessConfigCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceDeleteAccessConfigCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The instance name for this request. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceDeleteAccessConfigCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The name of the access config to delete. - /// - /// Sets the *access config* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn access_config(mut self, new_value: &str) -> InstanceDeleteAccessConfigCall<'a, C, A> { - self._access_config = new_value.to_string(); - self - } - /// The name of the network interface. - /// - /// Sets the *network interface* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn network_interface(mut self, new_value: &str) -> InstanceDeleteAccessConfigCall<'a, C, A> { - self._network_interface = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceDeleteAccessConfigCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceDeleteAccessConfigCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceDeleteAccessConfigCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Attaches a Disk resource to an instance. -/// -/// A builder for the *attachDisk* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::AttachedDisk; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = AttachedDisk::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.instances().attach_disk(req, "project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceAttachDiskCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: AttachedDisk, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceAttachDiskCall<'a, C, A> {} - -impl<'a, C, A> InstanceAttachDiskCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.attachDisk", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/attachDisk".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: AttachedDisk) -> InstanceAttachDiskCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceAttachDiskCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceAttachDiskCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The instance name for this request. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceAttachDiskCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceAttachDiskCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceAttachDiskCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceAttachDiskCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of instances contained within the specified zone. -/// -/// A builder for the *list* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().list("project", "zone") -/// .page_token("nonumy") -/// .max_results(86) -/// .filter("Lorem") -/// .doit(); -/// # } -/// ``` -pub struct InstanceListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceListCall<'a, C, A> {} - -impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceListCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> InstanceListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> InstanceListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> InstanceListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Starts an instance that was stopped using the using the instances().stop method. For more information, see Restart an instance. -/// -/// A builder for the *startWithEncryptionKey* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstancesStartWithEncryptionKeyRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstancesStartWithEncryptionKeyRequest::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.instances().start_with_encryption_key(req, "project", "zone", "instance") -/// .doit(); -/// # } -/// ``` -pub struct InstanceStartWithEncryptionKeyCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstancesStartWithEncryptionKeyRequest, - _project: String, - _zone: String, - _instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceStartWithEncryptionKeyCall<'a, C, A> {} - -impl<'a, C, A> InstanceStartWithEncryptionKeyCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.startWithEncryptionKey", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/startWithEncryptionKey".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instance}", "instance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstancesStartWithEncryptionKeyRequest) -> InstanceStartWithEncryptionKeyCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceStartWithEncryptionKeyCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceStartWithEncryptionKeyCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the instance resource to start. - /// - /// Sets the *instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance(mut self, new_value: &str) -> InstanceStartWithEncryptionKeyCall<'a, C, A> { - self._instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceStartWithEncryptionKeyCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceStartWithEncryptionKeyCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceStartWithEncryptionKeyCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves aggregated list of instances. -/// -/// A builder for the *aggregatedList* method supported by a *instance* resource. -/// It is not used directly, but through a `InstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instances().aggregated_list("project") -/// .page_token("amet.") -/// .max_results(1) -/// .filter("ut") -/// .doit(); -/// # } -/// ``` -pub struct InstanceAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> InstanceAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instances.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/instances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> InstanceAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> InstanceAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> InstanceAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Gets the most recent health check results for this BackendService. -/// -/// A builder for the *getHealth* method supported by a *backendService* resource. -/// It is not used directly, but through a `BackendServiceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::ResourceGroupReference; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = ResourceGroupReference::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.backend_services().get_health(req, "project", "backendService") -/// .doit(); -/// # } -/// ``` -pub struct BackendServiceGetHealthCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: ResourceGroupReference, - _project: String, - _backend_service: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for BackendServiceGetHealthCall<'a, C, A> {} - -impl<'a, C, A> BackendServiceGetHealthCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, BackendServiceGroupHealth)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.backendServices.getHealth", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("backendService", self._backend_service.to_string())); - for &field in ["alt", "project", "backendService"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices/{backendService}/getHealth".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{backendService}", "backendService")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["backendService", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: ResourceGroupReference) -> BackendServiceGetHealthCall<'a, C, A> { - self._request = new_value; - self - } - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> BackendServiceGetHealthCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the BackendService resource to which the queried instance belongs. - /// - /// Sets the *backend service* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn backend_service(mut self, new_value: &str) -> BackendServiceGetHealthCall<'a, C, A> { - self._backend_service = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> BackendServiceGetHealthCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> BackendServiceGetHealthCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> BackendServiceGetHealthCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified BackendService resource. -/// -/// A builder for the *delete* method supported by a *backendService* resource. -/// It is not used directly, but through a `BackendServiceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.backend_services().delete("project", "backendService") -/// .doit(); -/// # } -/// ``` -pub struct BackendServiceDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _backend_service: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for BackendServiceDeleteCall<'a, C, A> {} - -impl<'a, C, A> BackendServiceDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.backendServices.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("backendService", self._backend_service.to_string())); - for &field in ["alt", "project", "backendService"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices/{backendService}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{backendService}", "backendService")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["backendService", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> BackendServiceDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the BackendService resource to delete. - /// - /// Sets the *backend service* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn backend_service(mut self, new_value: &str) -> BackendServiceDeleteCall<'a, C, A> { - self._backend_service = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> BackendServiceDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> BackendServiceDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> BackendServiceDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified BackendService resource. Get a list of available backend services by making a list() request. -/// -/// A builder for the *get* method supported by a *backendService* resource. -/// It is not used directly, but through a `BackendServiceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.backend_services().get("project", "backendService") -/// .doit(); -/// # } -/// ``` -pub struct BackendServiceGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _backend_service: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for BackendServiceGetCall<'a, C, A> {} - -impl<'a, C, A> BackendServiceGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, BackendService)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.backendServices.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("backendService", self._backend_service.to_string())); - for &field in ["alt", "project", "backendService"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices/{backendService}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{backendService}", "backendService")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["backendService", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> BackendServiceGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the BackendService resource to return. - /// - /// Sets the *backend service* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn backend_service(mut self, new_value: &str) -> BackendServiceGetCall<'a, C, A> { - self._backend_service = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> BackendServiceGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> BackendServiceGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> BackendServiceGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates the entire content of the BackendService resource. There are several restrictions and guidelines to keep in mind when updating a backend service. Read Restrictions and Guidelines for more information. -/// -/// A builder for the *update* method supported by a *backendService* resource. -/// It is not used directly, but through a `BackendServiceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::BackendService; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = BackendService::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.backend_services().update(req, "project", "backendService") -/// .doit(); -/// # } -/// ``` -pub struct BackendServiceUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: BackendService, - _project: String, - _backend_service: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for BackendServiceUpdateCall<'a, C, A> {} - -impl<'a, C, A> BackendServiceUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.backendServices.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("backendService", self._backend_service.to_string())); - for &field in ["alt", "project", "backendService"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices/{backendService}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{backendService}", "backendService")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["backendService", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: BackendService) -> BackendServiceUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> BackendServiceUpdateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the BackendService resource to update. - /// - /// Sets the *backend service* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn backend_service(mut self, new_value: &str) -> BackendServiceUpdateCall<'a, C, A> { - self._backend_service = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> BackendServiceUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> BackendServiceUpdateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> BackendServiceUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of BackendService resources available to the specified project. -/// -/// A builder for the *list* method supported by a *backendService* resource. -/// It is not used directly, but through a `BackendServiceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.backend_services().list("project") -/// .page_token("vero") -/// .max_results(65) -/// .filter("sed") -/// .doit(); -/// # } -/// ``` -pub struct BackendServiceListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for BackendServiceListCall<'a, C, A> {} - -impl<'a, C, A> BackendServiceListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, BackendServiceList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.backendServices.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> BackendServiceListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> BackendServiceListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> BackendServiceListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> BackendServiceListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> BackendServiceListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> BackendServiceListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> BackendServiceListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates the entire content of the BackendService resource. There are several restrictions and guidelines to keep in mind when updating a backend service. Read Restrictions and Guidelines for more information. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *backendService* resource. -/// It is not used directly, but through a `BackendServiceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::BackendService; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = BackendService::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.backend_services().patch(req, "project", "backendService") -/// .doit(); -/// # } -/// ``` -pub struct BackendServicePatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: BackendService, - _project: String, - _backend_service: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for BackendServicePatchCall<'a, C, A> {} - -impl<'a, C, A> BackendServicePatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.backendServices.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("backendService", self._backend_service.to_string())); - for &field in ["alt", "project", "backendService"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices/{backendService}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{backendService}", "backendService")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["backendService", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: BackendService) -> BackendServicePatchCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> BackendServicePatchCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the BackendService resource to update. - /// - /// Sets the *backend service* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn backend_service(mut self, new_value: &str) -> BackendServicePatchCall<'a, C, A> { - self._backend_service = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> BackendServicePatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> BackendServicePatchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> BackendServicePatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a BackendService resource in the specified project using the data included in the request. There are several restrictions and guidelines to keep in mind when creating a backend service. Read Restrictions and Guidelines for more information. -/// -/// A builder for the *insert* method supported by a *backendService* resource. -/// It is not used directly, but through a `BackendServiceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::BackendService; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = BackendService::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.backend_services().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct BackendServiceInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: BackendService, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for BackendServiceInsertCall<'a, C, A> {} - -impl<'a, C, A> BackendServiceInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.backendServices.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: BackendService) -> BackendServiceInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> BackendServiceInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> BackendServiceInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> BackendServiceInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> BackendServiceInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of private images available to the specified project. Private images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. -/// -/// A builder for the *list* method supported by a *image* resource. -/// It is not used directly, but through a `ImageMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.images().list("project") -/// .page_token("vero") -/// .max_results(2) -/// .filter("takimata") -/// .doit(); -/// # } -/// ``` -pub struct ImageListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ImageListCall<'a, C, A> {} - -impl<'a, C, A> ImageListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ImageList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.images.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/images".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ImageListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ImageListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> ImageListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> ImageListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ImageListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ImageListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ImageListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the latest image that is part of an image family and is not deprecated. -/// -/// A builder for the *getFromFamily* method supported by a *image* resource. -/// It is not used directly, but through a `ImageMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.images().get_from_family("project", "family") -/// .doit(); -/// # } -/// ``` -pub struct ImageGetFromFamilyCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _family: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ImageGetFromFamilyCall<'a, C, A> {} - -impl<'a, C, A> ImageGetFromFamilyCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Image)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.images.getFromFamily", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("family", self._family.to_string())); - for &field in ["alt", "project", "family"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/images/family/{family}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{family}", "family")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["family", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ImageGetFromFamilyCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the image family to search for. - /// - /// Sets the *family* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn family(mut self, new_value: &str) -> ImageGetFromFamilyCall<'a, C, A> { - self._family = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ImageGetFromFamilyCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ImageGetFromFamilyCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ImageGetFromFamilyCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified image. -/// -/// A builder for the *delete* method supported by a *image* resource. -/// It is not used directly, but through a `ImageMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.images().delete("project", "image") -/// .doit(); -/// # } -/// ``` -pub struct ImageDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _image: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ImageDeleteCall<'a, C, A> {} - -impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.images.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("image", self._image.to_string())); - for &field in ["alt", "project", "image"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/images/{image}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{image}", "image")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["image", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ImageDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the image resource to delete. - /// - /// Sets the *image* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn image(mut self, new_value: &str) -> ImageDeleteCall<'a, C, A> { - self._image = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ImageDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ImageDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ImageDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Sets the deprecation status of an image. -/// -/// If an empty request body is given, clears the deprecation status instead. -/// -/// A builder for the *deprecate* method supported by a *image* resource. -/// It is not used directly, but through a `ImageMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::DeprecationStatus; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = DeprecationStatus::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.images().deprecate(req, "project", "image") -/// .doit(); -/// # } -/// ``` -pub struct ImageDeprecateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: DeprecationStatus, - _project: String, - _image: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ImageDeprecateCall<'a, C, A> {} - -impl<'a, C, A> ImageDeprecateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.images.deprecate", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("image", self._image.to_string())); - for &field in ["alt", "project", "image"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/images/{image}/deprecate".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{image}", "image")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["image", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: DeprecationStatus) -> ImageDeprecateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ImageDeprecateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Image name. - /// - /// Sets the *image* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn image(mut self, new_value: &str) -> ImageDeprecateCall<'a, C, A> { - self._image = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ImageDeprecateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ImageDeprecateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ImageDeprecateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates an image in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *image* resource. -/// It is not used directly, but through a `ImageMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Image; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Image::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.images().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct ImageInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Image, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ImageInsertCall<'a, C, A> {} - -impl<'a, C, A> ImageInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.images.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/images".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Image) -> ImageInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ImageInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ImageInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ImageInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ImageInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified image. Get a list of available images by making a list() request. -/// -/// A builder for the *get* method supported by a *image* resource. -/// It is not used directly, but through a `ImageMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.images().get("project", "image") -/// .doit(); -/// # } -/// ``` -pub struct ImageGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _image: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ImageGetCall<'a, C, A> {} - -impl<'a, C, A> ImageGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Image)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.images.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("image", self._image.to_string())); - for &field in ["alt", "project", "image"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/images/{image}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{image}", "image")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["image", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ImageGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the image resource to return. - /// - /// Sets the *image* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn image(mut self, new_value: &str) -> ImageGetCall<'a, C, A> { - self._image = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ImageGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ImageGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ImageGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified HealthCheck resource. Get a list of available health checks by making a list() request. -/// -/// A builder for the *get* method supported by a *healthCheck* resource. -/// It is not used directly, but through a `HealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.health_checks().get("project", "healthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HealthCheckGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HealthCheckGetCall<'a, C, A> {} - -impl<'a, C, A> HealthCheckGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, HealthCheck)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.healthChecks.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("healthCheck", self._health_check.to_string())); - for &field in ["alt", "project", "healthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks/{healthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{healthCheck}", "healthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["healthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HealthCheckGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HealthCheck resource to return. - /// - /// Sets the *health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn health_check(mut self, new_value: &str) -> HealthCheckGetCall<'a, C, A> { - self._health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HealthCheckGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HealthCheckGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HealthCheckGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates a HealthCheck resource in the specified project using the data included in the request. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *healthCheck* resource. -/// It is not used directly, but through a `HealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::HealthCheck; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = HealthCheck::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.health_checks().patch(req, "project", "healthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HealthCheckPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: HealthCheck, - _project: String, - _health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HealthCheckPatchCall<'a, C, A> {} - -impl<'a, C, A> HealthCheckPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.healthChecks.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("healthCheck", self._health_check.to_string())); - for &field in ["alt", "project", "healthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks/{healthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{healthCheck}", "healthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["healthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: HealthCheck) -> HealthCheckPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HealthCheckPatchCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HealthCheck resource to update. - /// - /// Sets the *health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn health_check(mut self, new_value: &str) -> HealthCheckPatchCall<'a, C, A> { - self._health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HealthCheckPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HealthCheckPatchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HealthCheckPatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a HealthCheck resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *healthCheck* resource. -/// It is not used directly, but through a `HealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::HealthCheck; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = HealthCheck::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.health_checks().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct HealthCheckInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: HealthCheck, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HealthCheckInsertCall<'a, C, A> {} - -impl<'a, C, A> HealthCheckInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.healthChecks.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: HealthCheck) -> HealthCheckInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HealthCheckInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HealthCheckInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HealthCheckInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HealthCheckInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates a HealthCheck resource in the specified project using the data included in the request. -/// -/// A builder for the *update* method supported by a *healthCheck* resource. -/// It is not used directly, but through a `HealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::HealthCheck; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = HealthCheck::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.health_checks().update(req, "project", "healthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HealthCheckUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: HealthCheck, - _project: String, - _health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HealthCheckUpdateCall<'a, C, A> {} - -impl<'a, C, A> HealthCheckUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.healthChecks.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("healthCheck", self._health_check.to_string())); - for &field in ["alt", "project", "healthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks/{healthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{healthCheck}", "healthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["healthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: HealthCheck) -> HealthCheckUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HealthCheckUpdateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HealthCheck resource to update. - /// - /// Sets the *health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn health_check(mut self, new_value: &str) -> HealthCheckUpdateCall<'a, C, A> { - self._health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HealthCheckUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HealthCheckUpdateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HealthCheckUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of HealthCheck resources available to the specified project. -/// -/// A builder for the *list* method supported by a *healthCheck* resource. -/// It is not used directly, but through a `HealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.health_checks().list("project") -/// .page_token("accusam") -/// .max_results(33) -/// .filter("consetetur") -/// .doit(); -/// # } -/// ``` -pub struct HealthCheckListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HealthCheckListCall<'a, C, A> {} - -impl<'a, C, A> HealthCheckListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, HealthCheckList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.healthChecks.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HealthCheckListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> HealthCheckListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> HealthCheckListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> HealthCheckListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HealthCheckListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HealthCheckListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HealthCheckListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified HealthCheck resource. -/// -/// A builder for the *delete* method supported by a *healthCheck* resource. -/// It is not used directly, but through a `HealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.health_checks().delete("project", "healthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HealthCheckDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HealthCheckDeleteCall<'a, C, A> {} - -impl<'a, C, A> HealthCheckDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.healthChecks.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("healthCheck", self._health_check.to_string())); - for &field in ["alt", "project", "healthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks/{healthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{healthCheck}", "healthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["healthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HealthCheckDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HealthCheck resource to delete. - /// - /// Sets the *health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn health_check(mut self, new_value: &str) -> HealthCheckDeleteCall<'a, C, A> { - self._health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HealthCheckDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HealthCheckDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HealthCheckDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified License resource. Get a list of available licenses by making a list() request. -/// -/// A builder for the *get* method supported by a *license* resource. -/// It is not used directly, but through a `LicenseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.licenses().get("project", "license") -/// .doit(); -/// # } -/// ``` -pub struct LicenseGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _license: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for LicenseGetCall<'a, C, A> {} - -impl<'a, C, A> LicenseGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, License)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.licenses.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("license", self._license.to_string())); - for &field in ["alt", "project", "license"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/licenses/{license}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{license}", "license")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["license", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> LicenseGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the License resource to return. - /// - /// Sets the *license* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn license(mut self, new_value: &str) -> LicenseGetCall<'a, C, A> { - self._license = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> LicenseGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> LicenseGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> LicenseGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified TargetHttpsProxy resource. -/// -/// A builder for the *delete* method supported by a *targetHttpsProxy* resource. -/// It is not used directly, but through a `TargetHttpsProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_https_proxies().delete("project", "targetHttpsProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpsProxyDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _target_https_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpsProxyDeleteCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpsProxyDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpsProxies.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetHttpsProxy", self._target_https_proxy.to_string())); - for &field in ["alt", "project", "targetHttpsProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpsProxies/{targetHttpsProxy}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetHttpsProxy}", "targetHttpsProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetHttpsProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpsProxyDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetHttpsProxy resource to delete. - /// - /// Sets the *target https proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_https_proxy(mut self, new_value: &str) -> TargetHttpsProxyDeleteCall<'a, C, A> { - self._target_https_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpsProxyDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpsProxyDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpsProxyDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified TargetHttpsProxy resource. Get a list of available target HTTPS proxies by making a list() request. -/// -/// A builder for the *get* method supported by a *targetHttpsProxy* resource. -/// It is not used directly, but through a `TargetHttpsProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_https_proxies().get("project", "targetHttpsProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpsProxyGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _target_https_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpsProxyGetCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpsProxyGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetHttpsProxy)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpsProxies.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetHttpsProxy", self._target_https_proxy.to_string())); - for &field in ["alt", "project", "targetHttpsProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpsProxies/{targetHttpsProxy}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetHttpsProxy}", "targetHttpsProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetHttpsProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpsProxyGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetHttpsProxy resource to return. - /// - /// Sets the *target https proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_https_proxy(mut self, new_value: &str) -> TargetHttpsProxyGetCall<'a, C, A> { - self._target_https_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpsProxyGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpsProxyGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpsProxyGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Changes the URL map for TargetHttpsProxy. -/// -/// A builder for the *setUrlMap* method supported by a *targetHttpsProxy* resource. -/// It is not used directly, but through a `TargetHttpsProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::UrlMapReference; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = UrlMapReference::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.target_https_proxies().set_url_map(req, "project", "targetHttpsProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpsProxySetUrlMapCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: UrlMapReference, - _project: String, - _target_https_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpsProxySetUrlMapCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpsProxySetUrlMapCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpsProxies.setUrlMap", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetHttpsProxy", self._target_https_proxy.to_string())); - for &field in ["alt", "project", "targetHttpsProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/targetHttpsProxies/{targetHttpsProxy}/setUrlMap".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetHttpsProxy}", "targetHttpsProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetHttpsProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: UrlMapReference) -> TargetHttpsProxySetUrlMapCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpsProxySetUrlMapCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetHttpsProxy resource whose URL map is to be set. - /// - /// Sets the *target https proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_https_proxy(mut self, new_value: &str) -> TargetHttpsProxySetUrlMapCall<'a, C, A> { - self._target_https_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpsProxySetUrlMapCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpsProxySetUrlMapCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpsProxySetUrlMapCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a TargetHttpsProxy resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *targetHttpsProxy* resource. -/// It is not used directly, but through a `TargetHttpsProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetHttpsProxy; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetHttpsProxy::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.target_https_proxies().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpsProxyInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetHttpsProxy, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpsProxyInsertCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpsProxyInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpsProxies.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpsProxies".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetHttpsProxy) -> TargetHttpsProxyInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpsProxyInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpsProxyInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpsProxyInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpsProxyInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Replaces SslCertificates for TargetHttpsProxy. -/// -/// A builder for the *setSslCertificates* method supported by a *targetHttpsProxy* resource. -/// It is not used directly, but through a `TargetHttpsProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetHttpsProxiesSetSslCertificatesRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetHttpsProxiesSetSslCertificatesRequest::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.target_https_proxies().set_ssl_certificates(req, "project", "targetHttpsProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpsProxySetSslCertificateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetHttpsProxiesSetSslCertificatesRequest, - _project: String, - _target_https_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpsProxySetSslCertificateCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpsProxySetSslCertificateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpsProxies.setSslCertificates", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetHttpsProxy", self._target_https_proxy.to_string())); - for &field in ["alt", "project", "targetHttpsProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/targetHttpsProxies/{targetHttpsProxy}/setSslCertificates".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetHttpsProxy}", "targetHttpsProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetHttpsProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetHttpsProxiesSetSslCertificatesRequest) -> TargetHttpsProxySetSslCertificateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpsProxySetSslCertificateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetHttpsProxy resource to set an SslCertificates resource for. - /// - /// Sets the *target https proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_https_proxy(mut self, new_value: &str) -> TargetHttpsProxySetSslCertificateCall<'a, C, A> { - self._target_https_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpsProxySetSslCertificateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpsProxySetSslCertificateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpsProxySetSslCertificateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of TargetHttpsProxy resources available to the specified project. -/// -/// A builder for the *list* method supported by a *targetHttpsProxy* resource. -/// It is not used directly, but through a `TargetHttpsProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_https_proxies().list("project") -/// .page_token("labore") -/// .max_results(40) -/// .filter("et") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpsProxyListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpsProxyListCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpsProxyListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetHttpsProxyList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpsProxies.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpsProxies".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpsProxyListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> TargetHttpsProxyListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> TargetHttpsProxyListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> TargetHttpsProxyListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpsProxyListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpsProxyListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpsProxyListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a network in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *network* resource. -/// It is not used directly, but through a `NetworkMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Network; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Network::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.networks().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct NetworkInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Network, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for NetworkInsertCall<'a, C, A> {} - -impl<'a, C, A> NetworkInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.networks.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/networks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Network) -> NetworkInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> NetworkInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> NetworkInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> NetworkInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> NetworkInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of networks available to the specified project. -/// -/// A builder for the *list* method supported by a *network* resource. -/// It is not used directly, but through a `NetworkMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.networks().list("project") -/// .page_token("magna") -/// .max_results(0) -/// .filter("rebum.") -/// .doit(); -/// # } -/// ``` -pub struct NetworkListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for NetworkListCall<'a, C, A> {} - -impl<'a, C, A> NetworkListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, NetworkList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.networks.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/networks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> NetworkListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> NetworkListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> NetworkListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> NetworkListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> NetworkListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> NetworkListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> NetworkListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified network. -/// -/// A builder for the *delete* method supported by a *network* resource. -/// It is not used directly, but through a `NetworkMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.networks().delete("project", "network") -/// .doit(); -/// # } -/// ``` -pub struct NetworkDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _network: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for NetworkDeleteCall<'a, C, A> {} - -impl<'a, C, A> NetworkDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.networks.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("network", self._network.to_string())); - for &field in ["alt", "project", "network"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{network}", "network")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["network", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> NetworkDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the network to delete. - /// - /// Sets the *network* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn network(mut self, new_value: &str) -> NetworkDeleteCall<'a, C, A> { - self._network = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> NetworkDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> NetworkDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> NetworkDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified network. Get a list of available networks by making a list() request. -/// -/// A builder for the *get* method supported by a *network* resource. -/// It is not used directly, but through a `NetworkMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.networks().get("project", "network") -/// .doit(); -/// # } -/// ``` -pub struct NetworkGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _network: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for NetworkGetCall<'a, C, A> {} - -impl<'a, C, A> NetworkGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Network)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.networks.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("network", self._network.to_string())); - for &field in ["alt", "project", "network"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{network}", "network")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["network", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> NetworkGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the network to return. - /// - /// Sets the *network* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn network(mut self, new_value: &str) -> NetworkGetCall<'a, C, A> { - self._network = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> NetworkGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> NetworkGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> NetworkGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of addresses contained within the specified region. -/// -/// A builder for the *list* method supported by a *addresse* resource. -/// It is not used directly, but through a `AddresseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.addresses().list("project", "region") -/// .page_token("vero") -/// .max_results(5) -/// .filter("eos") -/// .doit(); -/// # } -/// ``` -pub struct AddresseListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AddresseListCall<'a, C, A> {} - -impl<'a, C, A> AddresseListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, AddressList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.addresses.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "region", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AddresseListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> AddresseListCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> AddresseListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> AddresseListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> AddresseListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AddresseListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AddresseListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AddresseListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of addresses. -/// -/// A builder for the *aggregatedList* method supported by a *addresse* resource. -/// It is not used directly, but through a `AddresseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.addresses().aggregated_list("project") -/// .page_token("tempor") -/// .max_results(40) -/// .filter("dolore") -/// .doit(); -/// # } -/// ``` -pub struct AddresseAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AddresseAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, AddressAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.addresses.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/addresses".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AddresseAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> AddresseAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> AddresseAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> AddresseAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AddresseAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AddresseAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AddresseAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified address resource. -/// -/// A builder for the *get* method supported by a *addresse* resource. -/// It is not used directly, but through a `AddresseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.addresses().get("project", "region", "address") -/// .doit(); -/// # } -/// ``` -pub struct AddresseGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _address: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AddresseGetCall<'a, C, A> {} - -impl<'a, C, A> AddresseGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Address)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.addresses.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("address", self._address.to_string())); - for &field in ["alt", "project", "region", "address"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses/{address}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{address}", "address")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["address", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AddresseGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> AddresseGetCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the address resource to return. - /// - /// Sets the *address* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn address(mut self, new_value: &str) -> AddresseGetCall<'a, C, A> { - self._address = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AddresseGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AddresseGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AddresseGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates an address resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *addresse* resource. -/// It is not used directly, but through a `AddresseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Address; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Address::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.addresses().insert(req, "project", "region") -/// .doit(); -/// # } -/// ``` -pub struct AddresseInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Address, - _project: String, - _region: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AddresseInsertCall<'a, C, A> {} - -impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.addresses.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - for &field in ["alt", "project", "region"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Address) -> AddresseInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AddresseInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> AddresseInsertCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AddresseInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AddresseInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AddresseInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified address resource. -/// -/// A builder for the *delete* method supported by a *addresse* resource. -/// It is not used directly, but through a `AddresseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.addresses().delete("project", "region", "address") -/// .doit(); -/// # } -/// ``` -pub struct AddresseDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _address: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AddresseDeleteCall<'a, C, A> {} - -impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.addresses.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("address", self._address.to_string())); - for &field in ["alt", "project", "region", "address"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses/{address}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{address}", "address")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["address", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AddresseDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> AddresseDeleteCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the address resource to delete. - /// - /// Sets the *address* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn address(mut self, new_value: &str) -> AddresseDeleteCall<'a, C, A> { - self._address = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AddresseDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AddresseDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AddresseDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of Operation resources contained within the specified project. -/// -/// A builder for the *list* method supported by a *globalOperation* resource. -/// It is not used directly, but through a `GlobalOperationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.global_operations().list("project") -/// .page_token("diam") -/// .max_results(60) -/// .filter("sed") -/// .doit(); -/// # } -/// ``` -pub struct GlobalOperationListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalOperationListCall<'a, C, A> {} - -impl<'a, C, A> GlobalOperationListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, OperationList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalOperations.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalOperationListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> GlobalOperationListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> GlobalOperationListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> GlobalOperationListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalOperationListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalOperationListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalOperationListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the specified Operations resource. Get a list of operations by making a list() request. -/// -/// A builder for the *get* method supported by a *globalOperation* resource. -/// It is not used directly, but through a `GlobalOperationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.global_operations().get("project", "operation") -/// .doit(); -/// # } -/// ``` -pub struct GlobalOperationGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _operation: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalOperationGetCall<'a, C, A> {} - -impl<'a, C, A> GlobalOperationGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalOperations.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("operation", self._operation.to_string())); - for &field in ["alt", "project", "operation"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{operation}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{operation}", "operation")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["operation", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalOperationGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the Operations resource to return. - /// - /// Sets the *operation* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn operation(mut self, new_value: &str) -> GlobalOperationGetCall<'a, C, A> { - self._operation = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalOperationGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalOperationGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalOperationGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified Operations resource. -/// -/// A builder for the *delete* method supported by a *globalOperation* resource. -/// It is not used directly, but through a `GlobalOperationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.global_operations().delete("project", "operation") -/// .doit(); -/// # } -/// ``` -pub struct GlobalOperationDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _operation: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalOperationDeleteCall<'a, C, A> {} - -impl<'a, C, A> GlobalOperationDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalOperations.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("operation", self._operation.to_string())); - for &field in ["project", "operation"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{operation}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{operation}", "operation")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["operation", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = res; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalOperationDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the Operations resource to delete. - /// - /// Sets the *operation* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn operation(mut self, new_value: &str) -> GlobalOperationDeleteCall<'a, C, A> { - self._operation = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalOperationDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalOperationDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalOperationDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of all operations. -/// -/// A builder for the *aggregatedList* method supported by a *globalOperation* resource. -/// It is not used directly, but through a `GlobalOperationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.global_operations().aggregated_list("project") -/// .page_token("vero") -/// .max_results(10) -/// .filter("takimata") -/// .doit(); -/// # } -/// ``` -pub struct GlobalOperationAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalOperationAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> GlobalOperationAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, OperationAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalOperations.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/operations".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalOperationAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> GlobalOperationAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> GlobalOperationAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> GlobalOperationAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalOperationAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalOperationAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalOperationAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified autoscaler. -/// -/// A builder for the *delete* method supported by a *autoscaler* resource. -/// It is not used directly, but through a `AutoscalerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.autoscalers().delete("project", "zone", "autoscaler") -/// .doit(); -/// # } -/// ``` -pub struct AutoscalerDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _autoscaler: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AutoscalerDeleteCall<'a, C, A> {} - -impl<'a, C, A> AutoscalerDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.autoscalers.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("autoscaler", self._autoscaler.to_string())); - for &field in ["alt", "project", "zone", "autoscaler"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/autoscalers/{autoscaler}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{autoscaler}", "autoscaler")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["autoscaler", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AutoscalerDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> AutoscalerDeleteCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the autoscaler to delete. - /// - /// Sets the *autoscaler* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn autoscaler(mut self, new_value: &str) -> AutoscalerDeleteCall<'a, C, A> { - self._autoscaler = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AutoscalerDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AutoscalerDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified autoscaler resource. Get a list of available autoscalers by making a list() request. -/// -/// A builder for the *get* method supported by a *autoscaler* resource. -/// It is not used directly, but through a `AutoscalerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.autoscalers().get("project", "zone", "autoscaler") -/// .doit(); -/// # } -/// ``` -pub struct AutoscalerGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _autoscaler: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AutoscalerGetCall<'a, C, A> {} - -impl<'a, C, A> AutoscalerGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Autoscaler)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.autoscalers.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("autoscaler", self._autoscaler.to_string())); - for &field in ["alt", "project", "zone", "autoscaler"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/autoscalers/{autoscaler}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{autoscaler}", "autoscaler")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["autoscaler", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AutoscalerGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> AutoscalerGetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the autoscaler to return. - /// - /// Sets the *autoscaler* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn autoscaler(mut self, new_value: &str) -> AutoscalerGetCall<'a, C, A> { - self._autoscaler = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AutoscalerGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AutoscalerGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of autoscalers contained within the specified zone. -/// -/// A builder for the *list* method supported by a *autoscaler* resource. -/// It is not used directly, but through a `AutoscalerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.autoscalers().list("project", "zone") -/// .page_token("et") -/// .max_results(70) -/// .filter("nonumy") -/// .doit(); -/// # } -/// ``` -pub struct AutoscalerListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AutoscalerListCall<'a, C, A> {} - -impl<'a, C, A> AutoscalerListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, AutoscalerList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.autoscalers.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/autoscalers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AutoscalerListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> AutoscalerListCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> AutoscalerListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> AutoscalerListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> AutoscalerListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AutoscalerListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AutoscalerListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates an autoscaler in the specified project using the data included in the request. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *autoscaler* resource. -/// It is not used directly, but through a `AutoscalerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Autoscaler; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Autoscaler::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.autoscalers().patch(req, "project", "zone", "autoscaler") -/// .doit(); -/// # } -/// ``` -pub struct AutoscalerPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Autoscaler, - _project: String, - _zone: String, - _autoscaler: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AutoscalerPatchCall<'a, C, A> {} - -impl<'a, C, A> AutoscalerPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.autoscalers.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("autoscaler", self._autoscaler.to_string())); - for &field in ["alt", "project", "zone", "autoscaler"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/autoscalers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Autoscaler) -> AutoscalerPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AutoscalerPatchCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> AutoscalerPatchCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the autoscaler to update. - /// - /// Sets the *autoscaler* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn autoscaler(mut self, new_value: &str) -> AutoscalerPatchCall<'a, C, A> { - self._autoscaler = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AutoscalerPatchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AutoscalerPatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates an autoscaler in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *autoscaler* resource. -/// It is not used directly, but through a `AutoscalerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Autoscaler; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Autoscaler::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.autoscalers().insert(req, "project", "zone") -/// .doit(); -/// # } -/// ``` -pub struct AutoscalerInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Autoscaler, - _project: String, - _zone: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AutoscalerInsertCall<'a, C, A> {} - -impl<'a, C, A> AutoscalerInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.autoscalers.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - for &field in ["alt", "project", "zone"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/autoscalers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Autoscaler) -> AutoscalerInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AutoscalerInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> AutoscalerInsertCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AutoscalerInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AutoscalerInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of autoscalers. -/// -/// A builder for the *aggregatedList* method supported by a *autoscaler* resource. -/// It is not used directly, but through a `AutoscalerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.autoscalers().aggregated_list("project") -/// .page_token("gubergren") -/// .max_results(99) -/// .filter("amet") -/// .doit(); -/// # } -/// ``` -pub struct AutoscalerAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AutoscalerAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> AutoscalerAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, AutoscalerAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.autoscalers.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/autoscalers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AutoscalerAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> AutoscalerAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> AutoscalerAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> AutoscalerAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AutoscalerAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AutoscalerAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates an autoscaler in the specified project using the data included in the request. -/// -/// A builder for the *update* method supported by a *autoscaler* resource. -/// It is not used directly, but through a `AutoscalerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Autoscaler; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Autoscaler::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.autoscalers().update(req, "project", "zone") -/// .autoscaler("Lorem") -/// .doit(); -/// # } -/// ``` -pub struct AutoscalerUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Autoscaler, - _project: String, - _zone: String, - _autoscaler: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AutoscalerUpdateCall<'a, C, A> {} - -impl<'a, C, A> AutoscalerUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.autoscalers.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._autoscaler { - params.push(("autoscaler", value.to_string())); - } - for &field in ["alt", "project", "zone", "autoscaler"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/autoscalers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Autoscaler) -> AutoscalerUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> AutoscalerUpdateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> AutoscalerUpdateCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the autoscaler to update. - /// - /// Sets the *autoscaler* query property to the given value. - pub fn autoscaler(mut self, new_value: &str) -> AutoscalerUpdateCall<'a, C, A> { - self._autoscaler = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> AutoscalerUpdateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> AutoscalerUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a subnetwork in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *subnetwork* resource. -/// It is not used directly, but through a `SubnetworkMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Subnetwork; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Subnetwork::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.subnetworks().insert(req, "project", "region") -/// .doit(); -/// # } -/// ``` -pub struct SubnetworkInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Subnetwork, - _project: String, - _region: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SubnetworkInsertCall<'a, C, A> {} - -impl<'a, C, A> SubnetworkInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.subnetworks.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - for &field in ["alt", "project", "region"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Subnetwork) -> SubnetworkInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SubnetworkInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> SubnetworkInsertCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SubnetworkInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SubnetworkInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SubnetworkInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified subnetwork. Get a list of available subnetworks list() request. -/// -/// A builder for the *get* method supported by a *subnetwork* resource. -/// It is not used directly, but through a `SubnetworkMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.subnetworks().get("project", "region", "subnetwork") -/// .doit(); -/// # } -/// ``` -pub struct SubnetworkGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _subnetwork: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SubnetworkGetCall<'a, C, A> {} - -impl<'a, C, A> SubnetworkGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Subnetwork)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.subnetworks.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("subnetwork", self._subnetwork.to_string())); - for &field in ["alt", "project", "region", "subnetwork"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{subnetwork}", "subnetwork")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["subnetwork", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SubnetworkGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> SubnetworkGetCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the Subnetwork resource to return. - /// - /// Sets the *subnetwork* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn subnetwork(mut self, new_value: &str) -> SubnetworkGetCall<'a, C, A> { - self._subnetwork = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SubnetworkGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SubnetworkGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SubnetworkGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of subnetworks. -/// -/// A builder for the *aggregatedList* method supported by a *subnetwork* resource. -/// It is not used directly, but through a `SubnetworkMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.subnetworks().aggregated_list("project") -/// .page_token("sit") -/// .max_results(68) -/// .filter("et") -/// .doit(); -/// # } -/// ``` -pub struct SubnetworkAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SubnetworkAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> SubnetworkAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SubnetworkAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.subnetworks.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/subnetworks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SubnetworkAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> SubnetworkAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> SubnetworkAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> SubnetworkAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SubnetworkAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SubnetworkAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SubnetworkAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified subnetwork. -/// -/// A builder for the *delete* method supported by a *subnetwork* resource. -/// It is not used directly, but through a `SubnetworkMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.subnetworks().delete("project", "region", "subnetwork") -/// .doit(); -/// # } -/// ``` -pub struct SubnetworkDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _subnetwork: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SubnetworkDeleteCall<'a, C, A> {} - -impl<'a, C, A> SubnetworkDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.subnetworks.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("subnetwork", self._subnetwork.to_string())); - for &field in ["alt", "project", "region", "subnetwork"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{subnetwork}", "subnetwork")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["subnetwork", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SubnetworkDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> SubnetworkDeleteCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the Subnetwork resource to delete. - /// - /// Sets the *subnetwork* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn subnetwork(mut self, new_value: &str) -> SubnetworkDeleteCall<'a, C, A> { - self._subnetwork = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SubnetworkDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SubnetworkDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SubnetworkDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of subnetworks available to the specified project. -/// -/// A builder for the *list* method supported by a *subnetwork* resource. -/// It is not used directly, but through a `SubnetworkMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.subnetworks().list("project", "region") -/// .page_token("et") -/// .max_results(20) -/// .filter("dolores") -/// .doit(); -/// # } -/// ``` -pub struct SubnetworkListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SubnetworkListCall<'a, C, A> {} - -impl<'a, C, A> SubnetworkListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SubnetworkList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.subnetworks.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "region", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SubnetworkListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> SubnetworkListCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> SubnetworkListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> SubnetworkListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> SubnetworkListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SubnetworkListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SubnetworkListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SubnetworkListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information. -/// -/// A builder for the *delete* method supported by a *instanceGroup* resource. -/// It is not used directly, but through a `InstanceGroupMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_groups().delete("project", "zone", "instanceGroup") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance_group: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupDeleteCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroups.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroup", self._instance_group.to_string())); - for &field in ["alt", "project", "zone", "instanceGroup"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instanceGroup}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroup}", "instanceGroup")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroup", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupDeleteCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the instance group to delete. - /// - /// Sets the *instance group* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group(mut self, new_value: &str) -> InstanceGroupDeleteCall<'a, C, A> { - self._instance_group = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Lists the instances in the specified instance group. -/// -/// A builder for the *listInstances* method supported by a *instanceGroup* resource. -/// It is not used directly, but through a `InstanceGroupMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroupsListInstancesRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroupsListInstancesRequest::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.instance_groups().list_instances(req, "project", "zone", "instanceGroup") -/// .page_token("eos") -/// .max_results(54) -/// .filter("sed") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupListInstanceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroupsListInstancesRequest, - _project: String, - _zone: String, - _instance_group: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupListInstanceCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupListInstanceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceGroupsListInstances)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroups.listInstances", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroup", self._instance_group.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "zone", "instanceGroup", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instanceGroup}/listInstances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroup}", "instanceGroup")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroup", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroupsListInstancesRequest) -> InstanceGroupListInstanceCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupListInstanceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupListInstanceCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the instance group from which you want to generate a list of included instances. - /// - /// Sets the *instance group* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group(mut self, new_value: &str) -> InstanceGroupListInstanceCall<'a, C, A> { - self._instance_group = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> InstanceGroupListInstanceCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> InstanceGroupListInstanceCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> InstanceGroupListInstanceCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupListInstanceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupListInstanceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupListInstanceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information. -/// -/// A builder for the *addInstances* method supported by a *instanceGroup* resource. -/// It is not used directly, but through a `InstanceGroupMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroupsAddInstancesRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroupsAddInstancesRequest::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.instance_groups().add_instances(req, "project", "zone", "instanceGroup") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupAddInstanceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroupsAddInstancesRequest, - _project: String, - _zone: String, - _instance_group: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupAddInstanceCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupAddInstanceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroups.addInstances", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroup", self._instance_group.to_string())); - for &field in ["alt", "project", "zone", "instanceGroup"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instanceGroup}/addInstances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroup}", "instanceGroup")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroup", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroupsAddInstancesRequest) -> InstanceGroupAddInstanceCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupAddInstanceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupAddInstanceCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the instance group where you are adding instances. - /// - /// Sets the *instance group* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group(mut self, new_value: &str) -> InstanceGroupAddInstanceCall<'a, C, A> { - self._instance_group = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupAddInstanceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupAddInstanceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupAddInstanceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates an instance group in the specified project using the parameters that are included in the request. -/// -/// A builder for the *insert* method supported by a *instanceGroup* resource. -/// It is not used directly, but through a `InstanceGroupMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroup; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroup::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.instance_groups().insert(req, "project", "zone") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroup, - _project: String, - _zone: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupInsertCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroups.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - for &field in ["alt", "project", "zone"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroup) -> InstanceGroupInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where you want to create the instance group. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupInsertCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified instance group. Get a list of available instance groups by making a list() request. -/// -/// A builder for the *get* method supported by a *instanceGroup* resource. -/// It is not used directly, but through a `InstanceGroupMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_groups().get("project", "zone", "instanceGroup") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance_group: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupGetCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceGroup)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroups.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroup", self._instance_group.to_string())); - for &field in ["alt", "project", "zone", "instanceGroup"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instanceGroup}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroup}", "instanceGroup")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroup", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupGetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the instance group. - /// - /// Sets the *instance group* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group(mut self, new_value: &str) -> InstanceGroupGetCall<'a, C, A> { - self._instance_group = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Removes one or more instances from the specified instance group, but does not delete those instances. -/// -/// A builder for the *removeInstances* method supported by a *instanceGroup* resource. -/// It is not used directly, but through a `InstanceGroupMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroupsRemoveInstancesRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroupsRemoveInstancesRequest::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.instance_groups().remove_instances(req, "project", "zone", "instanceGroup") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupRemoveInstanceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroupsRemoveInstancesRequest, - _project: String, - _zone: String, - _instance_group: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupRemoveInstanceCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupRemoveInstanceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroups.removeInstances", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroup", self._instance_group.to_string())); - for &field in ["alt", "project", "zone", "instanceGroup"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instanceGroup}/removeInstances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroup}", "instanceGroup")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroup", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroupsRemoveInstancesRequest) -> InstanceGroupRemoveInstanceCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupRemoveInstanceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupRemoveInstanceCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the instance group where the specified instances will be removed. - /// - /// Sets the *instance group* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group(mut self, new_value: &str) -> InstanceGroupRemoveInstanceCall<'a, C, A> { - self._instance_group = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupRemoveInstanceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupRemoveInstanceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupRemoveInstanceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Sets the named ports for the specified instance group. -/// -/// A builder for the *setNamedPorts* method supported by a *instanceGroup* resource. -/// It is not used directly, but through a `InstanceGroupMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroupsSetNamedPortsRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroupsSetNamedPortsRequest::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.instance_groups().set_named_ports(req, "project", "zone", "instanceGroup") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupSetNamedPortCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroupsSetNamedPortsRequest, - _project: String, - _zone: String, - _instance_group: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupSetNamedPortCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupSetNamedPortCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroups.setNamedPorts", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroup", self._instance_group.to_string())); - for &field in ["alt", "project", "zone", "instanceGroup"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instanceGroup}/setNamedPorts".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroup}", "instanceGroup")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroup", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroupsSetNamedPortsRequest) -> InstanceGroupSetNamedPortCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupSetNamedPortCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupSetNamedPortCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the instance group where the named ports are updated. - /// - /// Sets the *instance group* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group(mut self, new_value: &str) -> InstanceGroupSetNamedPortCall<'a, C, A> { - self._instance_group = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupSetNamedPortCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupSetNamedPortCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupSetNamedPortCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of instance groups and sorts them by zone. -/// -/// A builder for the *aggregatedList* method supported by a *instanceGroup* resource. -/// It is not used directly, but through a `InstanceGroupMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_groups().aggregated_list("project") -/// .page_token("takimata") -/// .max_results(53) -/// .filter("takimata") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceGroupAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroups.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/instanceGroups".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> InstanceGroupAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> InstanceGroupAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> InstanceGroupAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of instance groups that are located in the specified project and zone. -/// -/// A builder for the *list* method supported by a *instanceGroup* resource. -/// It is not used directly, but through a `InstanceGroupMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_groups().list("project", "zone") -/// .page_token("aliquyam") -/// .max_results(18) -/// .filter("et") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupListCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceGroupList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroups.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupListCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> InstanceGroupListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> InstanceGroupListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> InstanceGroupListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of region resources available to the specified project. -/// -/// A builder for the *list* method supported by a *region* resource. -/// It is not used directly, but through a `RegionMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.regions().list("project") -/// .page_token("est") -/// .max_results(53) -/// .filter("et") -/// .doit(); -/// # } -/// ``` -pub struct RegionListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RegionListCall<'a, C, A> {} - -impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, RegionList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.regions.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RegionListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> RegionListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> RegionListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> RegionListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RegionListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RegionListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RegionListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified Region resource. Get a list of available regions by making a list() request. -/// -/// A builder for the *get* method supported by a *region* resource. -/// It is not used directly, but through a `RegionMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.regions().get("project", "region") -/// .doit(); -/// # } -/// ``` -pub struct RegionGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RegionGetCall<'a, C, A> {} - -impl<'a, C, A> RegionGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Region)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.regions.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - for &field in ["alt", "project", "region"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RegionGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region resource to return. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RegionGetCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RegionGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RegionGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RegionGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of forwarding rules. -/// -/// A builder for the *aggregatedList* method supported by a *forwardingRule* resource. -/// It is not used directly, but through a `ForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.forwarding_rules().aggregated_list("project") -/// .page_token("consetetur") -/// .max_results(28) -/// .filter("clita") -/// .doit(); -/// # } -/// ``` -pub struct ForwardingRuleAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ForwardingRuleAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> ForwardingRuleAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ForwardingRuleAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.forwardingRules.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/forwardingRules".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ForwardingRuleAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ForwardingRuleAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> ForwardingRuleAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> ForwardingRuleAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ForwardingRuleAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ForwardingRuleAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ForwardingRuleAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a ForwardingRule resource in the specified project and region using the data included in the request. -/// -/// A builder for the *insert* method supported by a *forwardingRule* resource. -/// It is not used directly, but through a `ForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::ForwardingRule; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = ForwardingRule::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.forwarding_rules().insert(req, "project", "region") -/// .doit(); -/// # } -/// ``` -pub struct ForwardingRuleInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: ForwardingRule, - _project: String, - _region: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ForwardingRuleInsertCall<'a, C, A> {} - -impl<'a, C, A> ForwardingRuleInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.forwardingRules.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - for &field in ["alt", "project", "region"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/forwardingRules".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: ForwardingRule) -> ForwardingRuleInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ForwardingRuleInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> ForwardingRuleInsertCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ForwardingRuleInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ForwardingRuleInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ForwardingRuleInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Changes target URL for forwarding rule. The new target should be of the same type as the old target. -/// -/// A builder for the *setTarget* method supported by a *forwardingRule* resource. -/// It is not used directly, but through a `ForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetReference; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetReference::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.forwarding_rules().set_target(req, "project", "region", "forwardingRule") -/// .doit(); -/// # } -/// ``` -pub struct ForwardingRuleSetTargetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetReference, - _project: String, - _region: String, - _forwarding_rule: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ForwardingRuleSetTargetCall<'a, C, A> {} - -impl<'a, C, A> ForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.forwardingRules.setTarget", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("forwardingRule", self._forwarding_rule.to_string())); - for &field in ["alt", "project", "region", "forwardingRule"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/forwardingRules/{forwardingRule}/setTarget".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{forwardingRule}", "forwardingRule")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["forwardingRule", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetReference) -> ForwardingRuleSetTargetCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ForwardingRuleSetTargetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> ForwardingRuleSetTargetCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the ForwardingRule resource in which target is to be set. - /// - /// Sets the *forwarding rule* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn forwarding_rule(mut self, new_value: &str) -> ForwardingRuleSetTargetCall<'a, C, A> { - self._forwarding_rule = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ForwardingRuleSetTargetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ForwardingRuleSetTargetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ForwardingRuleSetTargetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of ForwardingRule resources available to the specified project and region. -/// -/// A builder for the *list* method supported by a *forwardingRule* resource. -/// It is not used directly, but through a `ForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.forwarding_rules().list("project", "region") -/// .page_token("sit") -/// .max_results(3) -/// .filter("dolores") -/// .doit(); -/// # } -/// ``` -pub struct ForwardingRuleListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ForwardingRuleListCall<'a, C, A> {} - -impl<'a, C, A> ForwardingRuleListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ForwardingRuleList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.forwardingRules.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "region", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/forwardingRules".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ForwardingRuleListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> ForwardingRuleListCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ForwardingRuleListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> ForwardingRuleListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> ForwardingRuleListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ForwardingRuleListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ForwardingRuleListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ForwardingRuleListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified ForwardingRule resource. -/// -/// A builder for the *get* method supported by a *forwardingRule* resource. -/// It is not used directly, but through a `ForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.forwarding_rules().get("project", "region", "forwardingRule") -/// .doit(); -/// # } -/// ``` -pub struct ForwardingRuleGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _forwarding_rule: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ForwardingRuleGetCall<'a, C, A> {} - -impl<'a, C, A> ForwardingRuleGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ForwardingRule)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.forwardingRules.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("forwardingRule", self._forwarding_rule.to_string())); - for &field in ["alt", "project", "region", "forwardingRule"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/forwardingRules/{forwardingRule}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{forwardingRule}", "forwardingRule")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["forwardingRule", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ForwardingRuleGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> ForwardingRuleGetCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the ForwardingRule resource to return. - /// - /// Sets the *forwarding rule* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn forwarding_rule(mut self, new_value: &str) -> ForwardingRuleGetCall<'a, C, A> { - self._forwarding_rule = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ForwardingRuleGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ForwardingRuleGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ForwardingRuleGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified ForwardingRule resource. -/// -/// A builder for the *delete* method supported by a *forwardingRule* resource. -/// It is not used directly, but through a `ForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.forwarding_rules().delete("project", "region", "forwardingRule") -/// .doit(); -/// # } -/// ``` -pub struct ForwardingRuleDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _forwarding_rule: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ForwardingRuleDeleteCall<'a, C, A> {} - -impl<'a, C, A> ForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.forwardingRules.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("forwardingRule", self._forwarding_rule.to_string())); - for &field in ["alt", "project", "region", "forwardingRule"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/forwardingRules/{forwardingRule}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{forwardingRule}", "forwardingRule")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["forwardingRule", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ForwardingRuleDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> ForwardingRuleDeleteCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the ForwardingRule resource to delete. - /// - /// Sets the *forwarding rule* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn forwarding_rule(mut self, new_value: &str) -> ForwardingRuleDeleteCall<'a, C, A> { - self._forwarding_rule = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ForwardingRuleDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ForwardingRuleDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ForwardingRuleDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Adds health check URLs to a target pool. -/// -/// A builder for the *addHealthCheck* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetPoolsAddHealthCheckRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetPoolsAddHealthCheckRequest::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.target_pools().add_health_check(req, "project", "region", "targetPool") -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolAddHealthCheckCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetPoolsAddHealthCheckRequest, - _project: String, - _region: String, - _target_pool: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolAddHealthCheckCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolAddHealthCheckCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.addHealthCheck", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("targetPool", self._target_pool.to_string())); - for &field in ["alt", "project", "region", "targetPool"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools/{targetPool}/addHealthCheck".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{targetPool}", "targetPool")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetPool", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetPoolsAddHealthCheckRequest) -> TargetPoolAddHealthCheckCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolAddHealthCheckCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetPoolAddHealthCheckCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the target pool to add a health check to. - /// - /// Sets the *target pool* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_pool(mut self, new_value: &str) -> TargetPoolAddHealthCheckCall<'a, C, A> { - self._target_pool = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolAddHealthCheckCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolAddHealthCheckCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolAddHealthCheckCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a target pool in the specified project and region using the data included in the request. -/// -/// A builder for the *insert* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetPool; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetPool::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.target_pools().insert(req, "project", "region") -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetPool, - _project: String, - _region: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolInsertCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - for &field in ["alt", "project", "region"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetPool) -> TargetPoolInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetPoolInsertCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Removes health check URL from a target pool. -/// -/// A builder for the *removeHealthCheck* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetPoolsRemoveHealthCheckRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetPoolsRemoveHealthCheckRequest::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.target_pools().remove_health_check(req, "project", "region", "targetPool") -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolRemoveHealthCheckCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetPoolsRemoveHealthCheckRequest, - _project: String, - _region: String, - _target_pool: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolRemoveHealthCheckCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolRemoveHealthCheckCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.removeHealthCheck", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("targetPool", self._target_pool.to_string())); - for &field in ["alt", "project", "region", "targetPool"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools/{targetPool}/removeHealthCheck".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{targetPool}", "targetPool")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetPool", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetPoolsRemoveHealthCheckRequest) -> TargetPoolRemoveHealthCheckCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolRemoveHealthCheckCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetPoolRemoveHealthCheckCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the target pool to remove health checks from. - /// - /// Sets the *target pool* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_pool(mut self, new_value: &str) -> TargetPoolRemoveHealthCheckCall<'a, C, A> { - self._target_pool = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolRemoveHealthCheckCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolRemoveHealthCheckCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolRemoveHealthCheckCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Gets the most recent health check results for each IP for the instance that is referenced by the given target pool. -/// -/// A builder for the *getHealth* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceReference; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceReference::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.target_pools().get_health(req, "project", "region", "targetPool") -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolGetHealthCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceReference, - _project: String, - _region: String, - _target_pool: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolGetHealthCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolGetHealthCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetPoolInstanceHealth)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.getHealth", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("targetPool", self._target_pool.to_string())); - for &field in ["alt", "project", "region", "targetPool"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools/{targetPool}/getHealth".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{targetPool}", "targetPool")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetPool", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceReference) -> TargetPoolGetHealthCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolGetHealthCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetPoolGetHealthCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the TargetPool resource to which the queried instance belongs. - /// - /// Sets the *target pool* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_pool(mut self, new_value: &str) -> TargetPoolGetHealthCall<'a, C, A> { - self._target_pool = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolGetHealthCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolGetHealthCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolGetHealthCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Changes a backup target pool's configurations. -/// -/// A builder for the *setBackup* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetReference; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetReference::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.target_pools().set_backup(req, "project", "region", "targetPool") -/// .failover_ratio(0.715949137449) -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolSetBackupCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetReference, - _project: String, - _region: String, - _target_pool: String, - _failover_ratio: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolSetBackupCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolSetBackupCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.setBackup", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("targetPool", self._target_pool.to_string())); - if let Some(value) = self._failover_ratio { - params.push(("failoverRatio", value.to_string())); - } - for &field in ["alt", "project", "region", "targetPool", "failoverRatio"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools/{targetPool}/setBackup".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{targetPool}", "targetPool")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetPool", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetReference) -> TargetPoolSetBackupCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolSetBackupCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetPoolSetBackupCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the TargetPool resource to set a backup pool for. - /// - /// Sets the *target pool* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_pool(mut self, new_value: &str) -> TargetPoolSetBackupCall<'a, C, A> { - self._target_pool = new_value.to_string(); - self - } - /// New failoverRatio value for the target pool. - /// - /// Sets the *failover ratio* query property to the given value. - pub fn failover_ratio(mut self, new_value: f32) -> TargetPoolSetBackupCall<'a, C, A> { - self._failover_ratio = Some(new_value); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolSetBackupCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolSetBackupCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolSetBackupCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of target pools. -/// -/// A builder for the *aggregatedList* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_pools().aggregated_list("project") -/// .page_token("clita") -/// .max_results(39) -/// .filter("elitr") -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetPoolAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/targetPools".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> TargetPoolAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> TargetPoolAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> TargetPoolAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified target pool. Get a list of available target pools by making a list() request. -/// -/// A builder for the *get* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_pools().get("project", "region", "targetPool") -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _target_pool: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolGetCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetPool)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("targetPool", self._target_pool.to_string())); - for &field in ["alt", "project", "region", "targetPool"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools/{targetPool}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{targetPool}", "targetPool")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetPool", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetPoolGetCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the TargetPool resource to return. - /// - /// Sets the *target pool* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_pool(mut self, new_value: &str) -> TargetPoolGetCall<'a, C, A> { - self._target_pool = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Adds an instance to a target pool. -/// -/// A builder for the *addInstance* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetPoolsAddInstanceRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetPoolsAddInstanceRequest::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.target_pools().add_instance(req, "project", "region", "targetPool") -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolAddInstanceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetPoolsAddInstanceRequest, - _project: String, - _region: String, - _target_pool: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolAddInstanceCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolAddInstanceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.addInstance", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("targetPool", self._target_pool.to_string())); - for &field in ["alt", "project", "region", "targetPool"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools/{targetPool}/addInstance".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{targetPool}", "targetPool")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetPool", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetPoolsAddInstanceRequest) -> TargetPoolAddInstanceCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolAddInstanceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetPoolAddInstanceCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the TargetPool resource to add instances to. - /// - /// Sets the *target pool* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_pool(mut self, new_value: &str) -> TargetPoolAddInstanceCall<'a, C, A> { - self._target_pool = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolAddInstanceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolAddInstanceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolAddInstanceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Removes instance URL from a target pool. -/// -/// A builder for the *removeInstance* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetPoolsRemoveInstanceRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetPoolsRemoveInstanceRequest::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.target_pools().remove_instance(req, "project", "region", "targetPool") -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolRemoveInstanceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetPoolsRemoveInstanceRequest, - _project: String, - _region: String, - _target_pool: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolRemoveInstanceCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolRemoveInstanceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.removeInstance", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("targetPool", self._target_pool.to_string())); - for &field in ["alt", "project", "region", "targetPool"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools/{targetPool}/removeInstance".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{targetPool}", "targetPool")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetPool", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetPoolsRemoveInstanceRequest) -> TargetPoolRemoveInstanceCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolRemoveInstanceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetPoolRemoveInstanceCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the TargetPool resource to remove instances from. - /// - /// Sets the *target pool* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_pool(mut self, new_value: &str) -> TargetPoolRemoveInstanceCall<'a, C, A> { - self._target_pool = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolRemoveInstanceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolRemoveInstanceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolRemoveInstanceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified target pool. -/// -/// A builder for the *delete* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_pools().delete("project", "region", "targetPool") -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _target_pool: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolDeleteCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("targetPool", self._target_pool.to_string())); - for &field in ["alt", "project", "region", "targetPool"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools/{targetPool}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{targetPool}", "targetPool")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetPool", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetPoolDeleteCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the TargetPool resource to delete. - /// - /// Sets the *target pool* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_pool(mut self, new_value: &str) -> TargetPoolDeleteCall<'a, C, A> { - self._target_pool = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of target pools available to the specified project and region. -/// -/// A builder for the *list* method supported by a *targetPool* resource. -/// It is not used directly, but through a `TargetPoolMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_pools().list("project", "region") -/// .page_token("et") -/// .max_results(55) -/// .filter("et") -/// .doit(); -/// # } -/// ``` -pub struct TargetPoolListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetPoolListCall<'a, C, A> {} - -impl<'a, C, A> TargetPoolListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetPoolList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetPools.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "region", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetPoolListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region scoping this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetPoolListCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> TargetPoolListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> TargetPoolListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> TargetPoolListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetPoolListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetPoolListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetPoolListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of TargetInstance resources available to the specified project and zone. -/// -/// A builder for the *list* method supported by a *targetInstance* resource. -/// It is not used directly, but through a `TargetInstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_instances().list("project", "zone") -/// .page_token("kasd") -/// .max_results(51) -/// .filter("eos") -/// .doit(); -/// # } -/// ``` -pub struct TargetInstanceListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetInstanceListCall<'a, C, A> {} - -impl<'a, C, A> TargetInstanceListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetInstanceList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetInstances.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/targetInstances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetInstanceListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone scoping this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> TargetInstanceListCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> TargetInstanceListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> TargetInstanceListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> TargetInstanceListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetInstanceListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetInstanceListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetInstanceListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a TargetInstance resource in the specified project and zone using the data included in the request. -/// -/// A builder for the *insert* method supported by a *targetInstance* resource. -/// It is not used directly, but through a `TargetInstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetInstance; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetInstance::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.target_instances().insert(req, "project", "zone") -/// .doit(); -/// # } -/// ``` -pub struct TargetInstanceInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetInstance, - _project: String, - _zone: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetInstanceInsertCall<'a, C, A> {} - -impl<'a, C, A> TargetInstanceInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetInstances.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - for &field in ["alt", "project", "zone"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/targetInstances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetInstance) -> TargetInstanceInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetInstanceInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone scoping this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> TargetInstanceInsertCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetInstanceInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetInstanceInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetInstanceInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of target instances. -/// -/// A builder for the *aggregatedList* method supported by a *targetInstance* resource. -/// It is not used directly, but through a `TargetInstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_instances().aggregated_list("project") -/// .page_token("labore") -/// .max_results(70) -/// .filter("erat") -/// .doit(); -/// # } -/// ``` -pub struct TargetInstanceAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetInstanceAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> TargetInstanceAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetInstanceAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetInstances.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/targetInstances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetInstanceAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> TargetInstanceAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> TargetInstanceAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> TargetInstanceAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetInstanceAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetInstanceAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetInstanceAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified TargetInstance resource. -/// -/// A builder for the *delete* method supported by a *targetInstance* resource. -/// It is not used directly, but through a `TargetInstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_instances().delete("project", "zone", "targetInstance") -/// .doit(); -/// # } -/// ``` -pub struct TargetInstanceDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _target_instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetInstanceDeleteCall<'a, C, A> {} - -impl<'a, C, A> TargetInstanceDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetInstances.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("targetInstance", self._target_instance.to_string())); - for &field in ["alt", "project", "zone", "targetInstance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/targetInstances/{targetInstance}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{targetInstance}", "targetInstance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetInstance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetInstanceDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone scoping this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> TargetInstanceDeleteCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the TargetInstance resource to delete. - /// - /// Sets the *target instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_instance(mut self, new_value: &str) -> TargetInstanceDeleteCall<'a, C, A> { - self._target_instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetInstanceDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetInstanceDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetInstanceDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified TargetInstance resource. Get a list of available target instances by making a list() request. -/// -/// A builder for the *get* method supported by a *targetInstance* resource. -/// It is not used directly, but through a `TargetInstanceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_instances().get("project", "zone", "targetInstance") -/// .doit(); -/// # } -/// ``` -pub struct TargetInstanceGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _target_instance: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetInstanceGetCall<'a, C, A> {} - -impl<'a, C, A> TargetInstanceGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetInstance)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetInstances.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("targetInstance", self._target_instance.to_string())); - for &field in ["alt", "project", "zone", "targetInstance"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/targetInstances/{targetInstance}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{targetInstance}", "targetInstance")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetInstance", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetInstanceGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone scoping this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> TargetInstanceGetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the TargetInstance resource to return. - /// - /// Sets the *target instance* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_instance(mut self, new_value: &str) -> TargetInstanceGetCall<'a, C, A> { - self._target_instance = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetInstanceGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetInstanceGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetInstanceGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified ForwardingRule resource. -/// -/// A builder for the *delete* method supported by a *globalForwardingRule* resource. -/// It is not used directly, but through a `GlobalForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.global_forwarding_rules().delete("project", "forwardingRule") -/// .doit(); -/// # } -/// ``` -pub struct GlobalForwardingRuleDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _forwarding_rule: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalForwardingRuleDeleteCall<'a, C, A> {} - -impl<'a, C, A> GlobalForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalForwardingRules.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("forwardingRule", self._forwarding_rule.to_string())); - for &field in ["alt", "project", "forwardingRule"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/forwardingRules/{forwardingRule}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{forwardingRule}", "forwardingRule")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["forwardingRule", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalForwardingRuleDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the ForwardingRule resource to delete. - /// - /// Sets the *forwarding rule* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn forwarding_rule(mut self, new_value: &str) -> GlobalForwardingRuleDeleteCall<'a, C, A> { - self._forwarding_rule = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalForwardingRuleDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalForwardingRuleDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalForwardingRuleDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Changes target URL for forwarding rule. The new target should be of the same type as the old target. -/// -/// A builder for the *setTarget* method supported by a *globalForwardingRule* resource. -/// It is not used directly, but through a `GlobalForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetReference; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetReference::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.global_forwarding_rules().set_target(req, "project", "forwardingRule") -/// .doit(); -/// # } -/// ``` -pub struct GlobalForwardingRuleSetTargetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetReference, - _project: String, - _forwarding_rule: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalForwardingRuleSetTargetCall<'a, C, A> {} - -impl<'a, C, A> GlobalForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalForwardingRules.setTarget", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("forwardingRule", self._forwarding_rule.to_string())); - for &field in ["alt", "project", "forwardingRule"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/forwardingRules/{forwardingRule}/setTarget".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{forwardingRule}", "forwardingRule")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["forwardingRule", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetReference) -> GlobalForwardingRuleSetTargetCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalForwardingRuleSetTargetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the ForwardingRule resource in which target is to be set. - /// - /// Sets the *forwarding rule* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn forwarding_rule(mut self, new_value: &str) -> GlobalForwardingRuleSetTargetCall<'a, C, A> { - self._forwarding_rule = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalForwardingRuleSetTargetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalForwardingRuleSetTargetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalForwardingRuleSetTargetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a ForwardingRule resource in the specified project and region using the data included in the request. -/// -/// A builder for the *insert* method supported by a *globalForwardingRule* resource. -/// It is not used directly, but through a `GlobalForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::ForwardingRule; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = ForwardingRule::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.global_forwarding_rules().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct GlobalForwardingRuleInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: ForwardingRule, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalForwardingRuleInsertCall<'a, C, A> {} - -impl<'a, C, A> GlobalForwardingRuleInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalForwardingRules.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/forwardingRules".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: ForwardingRule) -> GlobalForwardingRuleInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalForwardingRuleInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalForwardingRuleInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalForwardingRuleInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalForwardingRuleInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of ForwardingRule resources available to the specified project. -/// -/// A builder for the *list* method supported by a *globalForwardingRule* resource. -/// It is not used directly, but through a `GlobalForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.global_forwarding_rules().list("project") -/// .page_token("et") -/// .max_results(71) -/// .filter("sanctus") -/// .doit(); -/// # } -/// ``` -pub struct GlobalForwardingRuleListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalForwardingRuleListCall<'a, C, A> {} - -impl<'a, C, A> GlobalForwardingRuleListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ForwardingRuleList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalForwardingRules.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/forwardingRules".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalForwardingRuleListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> GlobalForwardingRuleListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> GlobalForwardingRuleListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> GlobalForwardingRuleListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalForwardingRuleListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalForwardingRuleListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalForwardingRuleListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified ForwardingRule resource. Get a list of available forwarding rules by making a list() request. -/// -/// A builder for the *get* method supported by a *globalForwardingRule* resource. -/// It is not used directly, but through a `GlobalForwardingRuleMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.global_forwarding_rules().get("project", "forwardingRule") -/// .doit(); -/// # } -/// ``` -pub struct GlobalForwardingRuleGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _forwarding_rule: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GlobalForwardingRuleGetCall<'a, C, A> {} - -impl<'a, C, A> GlobalForwardingRuleGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ForwardingRule)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.globalForwardingRules.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("forwardingRule", self._forwarding_rule.to_string())); - for &field in ["alt", "project", "forwardingRule"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/forwardingRules/{forwardingRule}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{forwardingRule}", "forwardingRule")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["forwardingRule", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> GlobalForwardingRuleGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the ForwardingRule resource to return. - /// - /// Sets the *forwarding rule* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn forwarding_rule(mut self, new_value: &str) -> GlobalForwardingRuleGetCall<'a, C, A> { - self._forwarding_rule = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GlobalForwardingRuleGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> GlobalForwardingRuleGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> GlobalForwardingRuleGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified HttpsHealthCheck resource. -/// -/// A builder for the *delete* method supported by a *httpsHealthCheck* resource. -/// It is not used directly, but through a `HttpsHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.https_health_checks().delete("project", "httpsHealthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HttpsHealthCheckDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _https_health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpsHealthCheckDeleteCall<'a, C, A> {} - -impl<'a, C, A> HttpsHealthCheckDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpsHealthChecks.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("httpsHealthCheck", self._https_health_check.to_string())); - for &field in ["alt", "project", "httpsHealthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpsHealthChecks/{httpsHealthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{httpsHealthCheck}", "httpsHealthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["httpsHealthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpsHealthCheckDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HttpsHealthCheck resource to delete. - /// - /// Sets the *https health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn https_health_check(mut self, new_value: &str) -> HttpsHealthCheckDeleteCall<'a, C, A> { - self._https_health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpsHealthCheckDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpsHealthCheckDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpsHealthCheckDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of HttpsHealthCheck resources available to the specified project. -/// -/// A builder for the *list* method supported by a *httpsHealthCheck* resource. -/// It is not used directly, but through a `HttpsHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.https_health_checks().list("project") -/// .page_token("sit") -/// .max_results(62) -/// .filter("Stet") -/// .doit(); -/// # } -/// ``` -pub struct HttpsHealthCheckListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpsHealthCheckListCall<'a, C, A> {} - -impl<'a, C, A> HttpsHealthCheckListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, HttpsHealthCheckList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpsHealthChecks.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpsHealthChecks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpsHealthCheckListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> HttpsHealthCheckListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> HttpsHealthCheckListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> HttpsHealthCheckListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpsHealthCheckListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpsHealthCheckListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpsHealthCheckListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a HttpsHealthCheck resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *httpsHealthCheck* resource. -/// It is not used directly, but through a `HttpsHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::HttpsHealthCheck; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = HttpsHealthCheck::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.https_health_checks().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct HttpsHealthCheckInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: HttpsHealthCheck, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpsHealthCheckInsertCall<'a, C, A> {} - -impl<'a, C, A> HttpsHealthCheckInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpsHealthChecks.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpsHealthChecks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: HttpsHealthCheck) -> HttpsHealthCheckInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpsHealthCheckInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpsHealthCheckInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpsHealthCheckInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpsHealthCheckInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified HttpsHealthCheck resource. Get a list of available HTTPS health checks by making a list() request. -/// -/// A builder for the *get* method supported by a *httpsHealthCheck* resource. -/// It is not used directly, but through a `HttpsHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.https_health_checks().get("project", "httpsHealthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HttpsHealthCheckGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _https_health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpsHealthCheckGetCall<'a, C, A> {} - -impl<'a, C, A> HttpsHealthCheckGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, HttpsHealthCheck)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpsHealthChecks.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("httpsHealthCheck", self._https_health_check.to_string())); - for &field in ["alt", "project", "httpsHealthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpsHealthChecks/{httpsHealthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{httpsHealthCheck}", "httpsHealthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["httpsHealthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpsHealthCheckGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HttpsHealthCheck resource to return. - /// - /// Sets the *https health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn https_health_check(mut self, new_value: &str) -> HttpsHealthCheckGetCall<'a, C, A> { - self._https_health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpsHealthCheckGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpsHealthCheckGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpsHealthCheckGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates a HttpsHealthCheck resource in the specified project using the data included in the request. -/// -/// A builder for the *update* method supported by a *httpsHealthCheck* resource. -/// It is not used directly, but through a `HttpsHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::HttpsHealthCheck; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = HttpsHealthCheck::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.https_health_checks().update(req, "project", "httpsHealthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HttpsHealthCheckUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: HttpsHealthCheck, - _project: String, - _https_health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpsHealthCheckUpdateCall<'a, C, A> {} - -impl<'a, C, A> HttpsHealthCheckUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpsHealthChecks.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("httpsHealthCheck", self._https_health_check.to_string())); - for &field in ["alt", "project", "httpsHealthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpsHealthChecks/{httpsHealthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{httpsHealthCheck}", "httpsHealthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["httpsHealthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: HttpsHealthCheck) -> HttpsHealthCheckUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpsHealthCheckUpdateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HttpsHealthCheck resource to update. - /// - /// Sets the *https health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn https_health_check(mut self, new_value: &str) -> HttpsHealthCheckUpdateCall<'a, C, A> { - self._https_health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpsHealthCheckUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpsHealthCheckUpdateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpsHealthCheckUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates a HttpsHealthCheck resource in the specified project using the data included in the request. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *httpsHealthCheck* resource. -/// It is not used directly, but through a `HttpsHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::HttpsHealthCheck; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = HttpsHealthCheck::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.https_health_checks().patch(req, "project", "httpsHealthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HttpsHealthCheckPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: HttpsHealthCheck, - _project: String, - _https_health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpsHealthCheckPatchCall<'a, C, A> {} - -impl<'a, C, A> HttpsHealthCheckPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpsHealthChecks.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("httpsHealthCheck", self._https_health_check.to_string())); - for &field in ["alt", "project", "httpsHealthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpsHealthChecks/{httpsHealthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{httpsHealthCheck}", "httpsHealthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["httpsHealthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: HttpsHealthCheck) -> HttpsHealthCheckPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpsHealthCheckPatchCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HttpsHealthCheck resource to update. - /// - /// Sets the *https health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn https_health_check(mut self, new_value: &str) -> HttpsHealthCheckPatchCall<'a, C, A> { - self._https_health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpsHealthCheckPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpsHealthCheckPatchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpsHealthCheckPatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of routers. -/// -/// A builder for the *aggregatedList* method supported by a *router* resource. -/// It is not used directly, but through a `RouterMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.routers().aggregated_list("project") -/// .page_token("no") -/// .max_results(75) -/// .filter("sed") -/// .doit(); -/// # } -/// ``` -pub struct RouterAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouterAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> RouterAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, RouterAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routers.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/routers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouterAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> RouterAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> RouterAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> RouterAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouterAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouterAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouterAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified Router resource. Get a list of available routers by making a list() request. -/// -/// A builder for the *get* method supported by a *router* resource. -/// It is not used directly, but through a `RouterMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.routers().get("project", "region", "router") -/// .doit(); -/// # } -/// ``` -pub struct RouterGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _router: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouterGetCall<'a, C, A> {} - -impl<'a, C, A> RouterGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Router)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routers.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("router", self._router.to_string())); - for &field in ["alt", "project", "region", "router"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers/{router}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{router}", "router")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["router", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouterGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RouterGetCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the Router resource to return. - /// - /// Sets the *router* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn router(mut self, new_value: &str) -> RouterGetCall<'a, C, A> { - self._router = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouterGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouterGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouterGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of Router resources available to the specified project. -/// -/// A builder for the *list* method supported by a *router* resource. -/// It is not used directly, but through a `RouterMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.routers().list("project", "region") -/// .page_token("dolor") -/// .max_results(28) -/// .filter("diam") -/// .doit(); -/// # } -/// ``` -pub struct RouterListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouterListCall<'a, C, A> {} - -impl<'a, C, A> RouterListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, RouterList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routers.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "region", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouterListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RouterListCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> RouterListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> RouterListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> RouterListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouterListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouterListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouterListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves runtime information of the specified router. -/// -/// A builder for the *getRouterStatus* method supported by a *router* resource. -/// It is not used directly, but through a `RouterMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.routers().get_router_status("project", "region", "router") -/// .doit(); -/// # } -/// ``` -pub struct RouterGetRouterStatuCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _router: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouterGetRouterStatuCall<'a, C, A> {} - -impl<'a, C, A> RouterGetRouterStatuCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, RouterStatusResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routers.getRouterStatus", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("router", self._router.to_string())); - for &field in ["alt", "project", "region", "router"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers/{router}/getRouterStatus".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{router}", "router")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["router", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouterGetRouterStatuCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RouterGetRouterStatuCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the Router resource to query. - /// - /// Sets the *router* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn router(mut self, new_value: &str) -> RouterGetRouterStatuCall<'a, C, A> { - self._router = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouterGetRouterStatuCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouterGetRouterStatuCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouterGetRouterStatuCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates the entire content of the Router resource. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *router* resource. -/// It is not used directly, but through a `RouterMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Router; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Router::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.routers().patch(req, "project", "region", "router") -/// .doit(); -/// # } -/// ``` -pub struct RouterPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Router, - _project: String, - _region: String, - _router: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouterPatchCall<'a, C, A> {} - -impl<'a, C, A> RouterPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routers.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("router", self._router.to_string())); - for &field in ["alt", "project", "region", "router"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers/{router}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{router}", "router")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["router", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Router) -> RouterPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouterPatchCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RouterPatchCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the Router resource to update. - /// - /// Sets the *router* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn router(mut self, new_value: &str) -> RouterPatchCall<'a, C, A> { - self._router = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouterPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouterPatchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouterPatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified Router resource. -/// -/// A builder for the *delete* method supported by a *router* resource. -/// It is not used directly, but through a `RouterMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.routers().delete("project", "region", "router") -/// .doit(); -/// # } -/// ``` -pub struct RouterDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _router: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouterDeleteCall<'a, C, A> {} - -impl<'a, C, A> RouterDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routers.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("router", self._router.to_string())); - for &field in ["alt", "project", "region", "router"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers/{router}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{router}", "router")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["router", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouterDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RouterDeleteCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the Router resource to delete. - /// - /// Sets the *router* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn router(mut self, new_value: &str) -> RouterDeleteCall<'a, C, A> { - self._router = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouterDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouterDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouterDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a Router resource in the specified project and region using the data included in the request. -/// -/// A builder for the *insert* method supported by a *router* resource. -/// It is not used directly, but through a `RouterMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Router; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Router::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.routers().insert(req, "project", "region") -/// .doit(); -/// # } -/// ``` -pub struct RouterInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Router, - _project: String, - _region: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouterInsertCall<'a, C, A> {} - -impl<'a, C, A> RouterInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routers.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - for &field in ["alt", "project", "region"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Router) -> RouterInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouterInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RouterInsertCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouterInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouterInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouterInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates the entire content of the Router resource. -/// -/// A builder for the *update* method supported by a *router* resource. -/// It is not used directly, but through a `RouterMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Router; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Router::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.routers().update(req, "project", "region", "router") -/// .doit(); -/// # } -/// ``` -pub struct RouterUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Router, - _project: String, - _region: String, - _router: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouterUpdateCall<'a, C, A> {} - -impl<'a, C, A> RouterUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routers.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("router", self._router.to_string())); - for &field in ["alt", "project", "region", "router"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers/{router}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{router}", "router")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["router", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Router) -> RouterUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouterUpdateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RouterUpdateCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the Router resource to update. - /// - /// Sets the *router* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn router(mut self, new_value: &str) -> RouterUpdateCall<'a, C, A> { - self._router = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouterUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouterUpdateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouterUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Preview fields auto-generated during router create and update operations. Calling this method does NOT create or update the router. -/// -/// A builder for the *preview* method supported by a *router* resource. -/// It is not used directly, but through a `RouterMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Router; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Router::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.routers().preview(req, "project", "region", "router") -/// .doit(); -/// # } -/// ``` -pub struct RouterPreviewCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Router, - _project: String, - _region: String, - _router: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouterPreviewCall<'a, C, A> {} - -impl<'a, C, A> RouterPreviewCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, RoutersPreviewResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routers.preview", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("router", self._router.to_string())); - for &field in ["alt", "project", "region", "router"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers/{router}/preview".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{router}", "router")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["router", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Router) -> RouterPreviewCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouterPreviewCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RouterPreviewCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the Router resource to query. - /// - /// Sets the *router* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn router(mut self, new_value: &str) -> RouterPreviewCall<'a, C, A> { - self._router = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouterPreviewCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouterPreviewCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouterPreviewCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of machine types. -/// -/// A builder for the *aggregatedList* method supported by a *machineType* resource. -/// It is not used directly, but through a `MachineTypeMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.machine_types().aggregated_list("project") -/// .page_token("justo") -/// .max_results(93) -/// .filter("invidunt") -/// .doit(); -/// # } -/// ``` -pub struct MachineTypeAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for MachineTypeAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> MachineTypeAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, MachineTypeAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.machineTypes.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/machineTypes".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> MachineTypeAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> MachineTypeAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> MachineTypeAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> MachineTypeAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> MachineTypeAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> MachineTypeAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> MachineTypeAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified machine type. Get a list of available machine types by making a list() request. -/// -/// A builder for the *get* method supported by a *machineType* resource. -/// It is not used directly, but through a `MachineTypeMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.machine_types().get("project", "zone", "machineType") -/// .doit(); -/// # } -/// ``` -pub struct MachineTypeGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _machine_type: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for MachineTypeGetCall<'a, C, A> {} - -impl<'a, C, A> MachineTypeGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, MachineType)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.machineTypes.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("machineType", self._machine_type.to_string())); - for &field in ["alt", "project", "zone", "machineType"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/machineTypes/{machineType}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{machineType}", "machineType")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["machineType", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> MachineTypeGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> MachineTypeGetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the machine type to return. - /// - /// Sets the *machine type* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn machine_type(mut self, new_value: &str) -> MachineTypeGetCall<'a, C, A> { - self._machine_type = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> MachineTypeGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> MachineTypeGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> MachineTypeGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of machine types available to the specified project. -/// -/// A builder for the *list* method supported by a *machineType* resource. -/// It is not used directly, but through a `MachineTypeMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.machine_types().list("project", "zone") -/// .page_token("kasd") -/// .max_results(53) -/// .filter("justo") -/// .doit(); -/// # } -/// ``` -pub struct MachineTypeListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for MachineTypeListCall<'a, C, A> {} - -impl<'a, C, A> MachineTypeListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, MachineTypeList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.machineTypes.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/machineTypes".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> MachineTypeListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> MachineTypeListCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> MachineTypeListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> MachineTypeListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> MachineTypeListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> MachineTypeListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> MachineTypeListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> MachineTypeListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of target VPN gateways. -/// -/// A builder for the *aggregatedList* method supported by a *targetVpnGateway* resource. -/// It is not used directly, but through a `TargetVpnGatewayMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_vpn_gateways().aggregated_list("project") -/// .page_token("ipsum") -/// .max_results(100) -/// .filter("dolor") -/// .doit(); -/// # } -/// ``` -pub struct TargetVpnGatewayAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetVpnGatewayAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> TargetVpnGatewayAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetVpnGatewayAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetVpnGateways.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/targetVpnGateways".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetVpnGatewayAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> TargetVpnGatewayAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> TargetVpnGatewayAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> TargetVpnGatewayAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetVpnGatewayAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetVpnGatewayAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetVpnGatewayAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified target VPN gateway. Get a list of available target VPN gateways by making a list() request. -/// -/// A builder for the *get* method supported by a *targetVpnGateway* resource. -/// It is not used directly, but through a `TargetVpnGatewayMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_vpn_gateways().get("project", "region", "targetVpnGateway") -/// .doit(); -/// # } -/// ``` -pub struct TargetVpnGatewayGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _target_vpn_gateway: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetVpnGatewayGetCall<'a, C, A> {} - -impl<'a, C, A> TargetVpnGatewayGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetVpnGateway)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetVpnGateways.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("targetVpnGateway", self._target_vpn_gateway.to_string())); - for &field in ["alt", "project", "region", "targetVpnGateway"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetVpnGateways/{targetVpnGateway}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{targetVpnGateway}", "targetVpnGateway")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetVpnGateway", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetVpnGatewayGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetVpnGatewayGetCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the target VPN gateway to return. - /// - /// Sets the *target vpn gateway* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_vpn_gateway(mut self, new_value: &str) -> TargetVpnGatewayGetCall<'a, C, A> { - self._target_vpn_gateway = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetVpnGatewayGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetVpnGatewayGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetVpnGatewayGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of target VPN gateways available to the specified project and region. -/// -/// A builder for the *list* method supported by a *targetVpnGateway* resource. -/// It is not used directly, but through a `TargetVpnGatewayMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_vpn_gateways().list("project", "region") -/// .page_token("ea") -/// .max_results(85) -/// .filter("et") -/// .doit(); -/// # } -/// ``` -pub struct TargetVpnGatewayListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetVpnGatewayListCall<'a, C, A> {} - -impl<'a, C, A> TargetVpnGatewayListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetVpnGatewayList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetVpnGateways.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "region", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetVpnGateways".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetVpnGatewayListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetVpnGatewayListCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> TargetVpnGatewayListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> TargetVpnGatewayListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> TargetVpnGatewayListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetVpnGatewayListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetVpnGatewayListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetVpnGatewayListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a target VPN gateway in the specified project and region using the data included in the request. -/// -/// A builder for the *insert* method supported by a *targetVpnGateway* resource. -/// It is not used directly, but through a `TargetVpnGatewayMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetVpnGateway; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetVpnGateway::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.target_vpn_gateways().insert(req, "project", "region") -/// .doit(); -/// # } -/// ``` -pub struct TargetVpnGatewayInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetVpnGateway, - _project: String, - _region: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetVpnGatewayInsertCall<'a, C, A> {} - -impl<'a, C, A> TargetVpnGatewayInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetVpnGateways.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - for &field in ["alt", "project", "region"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetVpnGateways".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetVpnGateway) -> TargetVpnGatewayInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetVpnGatewayInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetVpnGatewayInsertCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetVpnGatewayInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetVpnGatewayInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetVpnGatewayInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified target VPN gateway. -/// -/// A builder for the *delete* method supported by a *targetVpnGateway* resource. -/// It is not used directly, but through a `TargetVpnGatewayMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_vpn_gateways().delete("project", "region", "targetVpnGateway") -/// .doit(); -/// # } -/// ``` -pub struct TargetVpnGatewayDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _target_vpn_gateway: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetVpnGatewayDeleteCall<'a, C, A> {} - -impl<'a, C, A> TargetVpnGatewayDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetVpnGateways.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("targetVpnGateway", self._target_vpn_gateway.to_string())); - for &field in ["alt", "project", "region", "targetVpnGateway"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetVpnGateways/{targetVpnGateway}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{targetVpnGateway}", "targetVpnGateway")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["targetVpnGateway", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetVpnGatewayDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> TargetVpnGatewayDeleteCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the target VPN gateway to delete. - /// - /// Sets the *target vpn gateway* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_vpn_gateway(mut self, new_value: &str) -> TargetVpnGatewayDeleteCall<'a, C, A> { - self._target_vpn_gateway = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetVpnGatewayDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetVpnGatewayDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetVpnGatewayDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. -/// -/// A builder for the *resize* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_group_managers().resize("project", "zone", "instanceGroupManager", -38) -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerResizeCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance_group_manager: String, - _size: i32, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerResizeCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerResizeCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.resize", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroupManager", self._instance_group_manager.to_string())); - params.push(("size", self._size.to_string())); - for &field in ["alt", "project", "zone", "instanceGroupManager", "size"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/resize".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroupManager}", "instanceGroupManager")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroupManager", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerResizeCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the managed instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerResizeCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the managed instance group. - /// - /// Sets the *instance group manager* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group_manager(mut self, new_value: &str) -> InstanceGroupManagerResizeCall<'a, C, A> { - self._instance_group_manager = new_value.to_string(); - self - } - /// The number of running instances that the managed instance group should maintain at any given time. The group automatically adds or removes instances to maintain the number of instances specified by this parameter. - /// - /// Sets the *size* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn size(mut self, new_value: i32) -> InstanceGroupManagerResizeCall<'a, C, A> { - self._size = new_value; - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerResizeCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerResizeCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerResizeCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. -/// -/// A builder for the *listManagedInstances* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_group_managers().list_managed_instances("project", "zone", "instanceGroupManager") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerListManagedInstanceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance_group_manager: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerListManagedInstanceCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerListManagedInstanceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceGroupManagersListManagedInstancesResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.listManagedInstances", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroupManager", self._instance_group_manager.to_string())); - for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/listManagedInstances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroupManager}", "instanceGroupManager")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroupManager", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerListManagedInstanceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the managed instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerListManagedInstanceCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the managed instance group. - /// - /// Sets the *instance group manager* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group_manager(mut self, new_value: &str) -> InstanceGroupManagerListManagedInstanceCall<'a, C, A> { - self._instance_group_manager = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerListManagedInstanceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerListManagedInstanceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerListManagedInstanceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a managed instance group using the information that you specify in the request. After the group is created, it schedules an action to create instances in the group using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. -/// -/// A builder for the *insert* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroupManager; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroupManager::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.instance_group_managers().insert(req, "project", "zone") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroupManager, - _project: String, - _zone: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerInsertCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - for &field in ["alt", "project", "zone"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroupManager) -> InstanceGroupManagerInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where you want to create the managed instance group. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerInsertCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of managed instance groups and groups them by zone. -/// -/// A builder for the *aggregatedList* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_group_managers().aggregated_list("project") -/// .page_token("sed") -/// .max_results(41) -/// .filter("amet.") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceGroupManagerAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/instanceGroupManagers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> InstanceGroupManagerAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> InstanceGroupManagerAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> InstanceGroupManagerAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Schedules a group action to delete the specified instances in the managed instance group. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. -/// -/// A builder for the *deleteInstances* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroupManagersDeleteInstancesRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroupManagersDeleteInstancesRequest::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.instance_group_managers().delete_instances(req, "project", "zone", "instanceGroupManager") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerDeleteInstanceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroupManagersDeleteInstancesRequest, - _project: String, - _zone: String, - _instance_group_manager: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerDeleteInstanceCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerDeleteInstanceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.deleteInstances", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroupManager", self._instance_group_manager.to_string())); - for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/deleteInstances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroupManager}", "instanceGroupManager")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroupManager", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroupManagersDeleteInstancesRequest) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the managed instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the managed instance group. - /// - /// Sets the *instance group manager* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group_manager(mut self, new_value: &str) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> { - self._instance_group_manager = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerDeleteInstanceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of managed instance groups that are contained within the specified project and zone. -/// -/// A builder for the *list* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_group_managers().list("project", "zone") -/// .page_token("dolore") -/// .max_results(57) -/// .filter("ipsum") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerListCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceGroupManagerList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the managed instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerListCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> InstanceGroupManagerListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> InstanceGroupManagerListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> InstanceGroupManagerListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group. -/// -/// A builder for the *setTargetPools* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroupManagersSetTargetPoolsRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroupManagersSetTargetPoolsRequest::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.instance_group_managers().set_target_pools(req, "project", "zone", "instanceGroupManager") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerSetTargetPoolCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroupManagersSetTargetPoolsRequest, - _project: String, - _zone: String, - _instance_group_manager: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerSetTargetPoolCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerSetTargetPoolCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.setTargetPools", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroupManager", self._instance_group_manager.to_string())); - for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/setTargetPools".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroupManager}", "instanceGroupManager")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroupManager", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroupManagersSetTargetPoolsRequest) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the managed instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the managed instance group. - /// - /// Sets the *instance group manager* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group_manager(mut self, new_value: &str) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> { - self._instance_group_manager = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerSetTargetPoolCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you recreate them. -/// -/// A builder for the *setInstanceTemplate* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroupManagersSetInstanceTemplateRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroupManagersSetInstanceTemplateRequest::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.instance_group_managers().set_instance_template(req, "project", "zone", "instanceGroupManager") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroupManagersSetInstanceTemplateRequest, - _project: String, - _zone: String, - _instance_group_manager: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.setInstanceTemplate", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroupManager", self._instance_group_manager.to_string())); - for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/setInstanceTemplate".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroupManager}", "instanceGroupManager")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroupManager", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroupManagersSetInstanceTemplateRequest) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the managed instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the managed instance group. - /// - /// Sets the *instance group manager* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group_manager(mut self, new_value: &str) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> { - self._instance_group_manager = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information. -/// -/// A builder for the *delete* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_group_managers().delete("project", "zone", "instanceGroupManager") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance_group_manager: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerDeleteCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroupManager", self._instance_group_manager.to_string())); - for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroupManager}", "instanceGroupManager")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroupManager", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the managed instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerDeleteCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the managed instance group to delete. - /// - /// Sets the *instance group manager* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group_manager(mut self, new_value: &str) -> InstanceGroupManagerDeleteCall<'a, C, A> { - self._instance_group_manager = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns all of the details about the specified managed instance group. Get a list of available managed instance groups by making a list() request. -/// -/// A builder for the *get* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_group_managers().get("project", "zone", "instanceGroupManager") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _instance_group_manager: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerGetCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceGroupManager)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroupManager", self._instance_group_manager.to_string())); - for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroupManager}", "instanceGroupManager")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroupManager", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the managed instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerGetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the managed instance group. - /// - /// Sets the *instance group manager* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group_manager(mut self, new_value: &str) -> InstanceGroupManagerGetCall<'a, C, A> { - self._instance_group_manager = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Schedules a group action to remove the specified instances from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. -/// -/// A builder for the *abandonInstances* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroupManagersAbandonInstancesRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroupManagersAbandonInstancesRequest::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.instance_group_managers().abandon_instances(req, "project", "zone", "instanceGroupManager") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerAbandonInstanceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroupManagersAbandonInstancesRequest, - _project: String, - _zone: String, - _instance_group_manager: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerAbandonInstanceCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerAbandonInstanceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.abandonInstances", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroupManager", self._instance_group_manager.to_string())); - for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/abandonInstances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroupManager}", "instanceGroupManager")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroupManager", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroupManagersAbandonInstancesRequest) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the managed instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the managed instance group. - /// - /// Sets the *instance group manager* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group_manager(mut self, new_value: &str) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> { - self._instance_group_manager = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerAbandonInstanceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Schedules a group action to recreate the specified instances in the managed instance group. The instances are deleted and recreated using the current instance template for the managed instance group. This operation is marked as DONE when the action is scheduled even if the instances have not yet been recreated. You must separately verify the status of the recreating action with the listmanagedinstances method. -/// -/// A builder for the *recreateInstances* method supported by a *instanceGroupManager* resource. -/// It is not used directly, but through a `InstanceGroupManagerMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceGroupManagersRecreateInstancesRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceGroupManagersRecreateInstancesRequest::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.instance_group_managers().recreate_instances(req, "project", "zone", "instanceGroupManager") -/// .doit(); -/// # } -/// ``` -pub struct InstanceGroupManagerRecreateInstanceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceGroupManagersRecreateInstancesRequest, - _project: String, - _zone: String, - _instance_group_manager: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceGroupManagerRecreateInstanceCall<'a, C, A> {} - -impl<'a, C, A> InstanceGroupManagerRecreateInstanceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceGroupManagers.recreateInstances", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("instanceGroupManager", self._instance_group_manager.to_string())); - for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/recreateInstances".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroupManager}", "instanceGroupManager")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["instanceGroupManager", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceGroupManagersRecreateInstancesRequest) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the zone where the managed instance group is located. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// The name of the managed instance group. - /// - /// Sets the *instance group manager* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_group_manager(mut self, new_value: &str) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> { - self._instance_group_manager = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerRecreateInstanceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Moves a persistent disk from one zone to another. -/// -/// A builder for the *moveDisk* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::DiskMoveRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = DiskMoveRequest::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.projects().move_disk(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct ProjectMoveDiskCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: DiskMoveRequest, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectMoveDiskCall<'a, C, A> {} - -impl<'a, C, A> ProjectMoveDiskCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.projects.moveDisk", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/moveDisk".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: DiskMoveRequest) -> ProjectMoveDiskCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ProjectMoveDiskCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectMoveDiskCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectMoveDiskCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectMoveDiskCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Sets metadata common to all instances within the specified project using the data included in the request. -/// -/// A builder for the *setCommonInstanceMetadata* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Metadata; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Metadata::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.projects().set_common_instance_metadata(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct ProjectSetCommonInstanceMetadataCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Metadata, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectSetCommonInstanceMetadataCall<'a, C, A> {} - -impl<'a, C, A> ProjectSetCommonInstanceMetadataCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.projects.setCommonInstanceMetadata", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/setCommonInstanceMetadata".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Metadata) -> ProjectSetCommonInstanceMetadataCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ProjectSetCommonInstanceMetadataCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectSetCommonInstanceMetadataCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectSetCommonInstanceMetadataCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectSetCommonInstanceMetadataCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Moves an instance and its attached persistent disks from one zone to another. -/// -/// A builder for the *moveInstance* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceMoveRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceMoveRequest::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.projects().move_instance(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct ProjectMoveInstanceCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceMoveRequest, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectMoveInstanceCall<'a, C, A> {} - -impl<'a, C, A> ProjectMoveInstanceCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.projects.moveInstance", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/moveInstance".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceMoveRequest) -> ProjectMoveInstanceCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ProjectMoveInstanceCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectMoveInstanceCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectMoveInstanceCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectMoveInstanceCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide an empty request body using this method, the usage export feature will be disabled. -/// -/// A builder for the *setUsageExportBucket* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::UsageExportLocation; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = UsageExportLocation::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.projects().set_usage_export_bucket(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct ProjectSetUsageExportBucketCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: UsageExportLocation, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectSetUsageExportBucketCall<'a, C, A> {} - -impl<'a, C, A> ProjectSetUsageExportBucketCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.projects.setUsageExportBucket", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/setUsageExportBucket".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: UsageExportLocation) -> ProjectSetUsageExportBucketCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ProjectSetUsageExportBucketCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectSetUsageExportBucketCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectSetUsageExportBucketCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectSetUsageExportBucketCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified Project resource. -/// -/// A builder for the *get* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.projects().get("project") -/// .doit(); -/// # } -/// ``` -pub struct ProjectGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectGetCall<'a, C, A> {} - -impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Project)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.projects.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ProjectGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified HttpHealthCheck resource. Get a list of available HTTP health checks by making a list() request. -/// -/// A builder for the *get* method supported by a *httpHealthCheck* resource. -/// It is not used directly, but through a `HttpHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.http_health_checks().get("project", "httpHealthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HttpHealthCheckGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _http_health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpHealthCheckGetCall<'a, C, A> {} - -impl<'a, C, A> HttpHealthCheckGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, HttpHealthCheck)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpHealthChecks.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("httpHealthCheck", self._http_health_check.to_string())); - for &field in ["alt", "project", "httpHealthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpHealthChecks/{httpHealthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{httpHealthCheck}", "httpHealthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["httpHealthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpHealthCheckGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HttpHealthCheck resource to return. - /// - /// Sets the *http health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn http_health_check(mut self, new_value: &str) -> HttpHealthCheckGetCall<'a, C, A> { - self._http_health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpHealthCheckGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpHealthCheckGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpHealthCheckGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified HttpHealthCheck resource. -/// -/// A builder for the *delete* method supported by a *httpHealthCheck* resource. -/// It is not used directly, but through a `HttpHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.http_health_checks().delete("project", "httpHealthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HttpHealthCheckDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _http_health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpHealthCheckDeleteCall<'a, C, A> {} - -impl<'a, C, A> HttpHealthCheckDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpHealthChecks.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("httpHealthCheck", self._http_health_check.to_string())); - for &field in ["alt", "project", "httpHealthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpHealthChecks/{httpHealthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{httpHealthCheck}", "httpHealthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["httpHealthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpHealthCheckDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HttpHealthCheck resource to delete. - /// - /// Sets the *http health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn http_health_check(mut self, new_value: &str) -> HttpHealthCheckDeleteCall<'a, C, A> { - self._http_health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpHealthCheckDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpHealthCheckDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpHealthCheckDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates a HttpHealthCheck resource in the specified project using the data included in the request. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *httpHealthCheck* resource. -/// It is not used directly, but through a `HttpHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::HttpHealthCheck; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = HttpHealthCheck::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.http_health_checks().patch(req, "project", "httpHealthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HttpHealthCheckPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: HttpHealthCheck, - _project: String, - _http_health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpHealthCheckPatchCall<'a, C, A> {} - -impl<'a, C, A> HttpHealthCheckPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpHealthChecks.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("httpHealthCheck", self._http_health_check.to_string())); - for &field in ["alt", "project", "httpHealthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpHealthChecks/{httpHealthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{httpHealthCheck}", "httpHealthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["httpHealthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: HttpHealthCheck) -> HttpHealthCheckPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpHealthCheckPatchCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HttpHealthCheck resource to update. - /// - /// Sets the *http health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn http_health_check(mut self, new_value: &str) -> HttpHealthCheckPatchCall<'a, C, A> { - self._http_health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpHealthCheckPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpHealthCheckPatchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpHealthCheckPatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of HttpHealthCheck resources available to the specified project. -/// -/// A builder for the *list* method supported by a *httpHealthCheck* resource. -/// It is not used directly, but through a `HttpHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.http_health_checks().list("project") -/// .page_token("eos") -/// .max_results(7) -/// .filter("tempor") -/// .doit(); -/// # } -/// ``` -pub struct HttpHealthCheckListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpHealthCheckListCall<'a, C, A> {} - -impl<'a, C, A> HttpHealthCheckListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, HttpHealthCheckList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpHealthChecks.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpHealthChecks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpHealthCheckListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> HttpHealthCheckListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> HttpHealthCheckListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> HttpHealthCheckListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpHealthCheckListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpHealthCheckListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpHealthCheckListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a HttpHealthCheck resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *httpHealthCheck* resource. -/// It is not used directly, but through a `HttpHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::HttpHealthCheck; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = HttpHealthCheck::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.http_health_checks().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct HttpHealthCheckInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: HttpHealthCheck, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpHealthCheckInsertCall<'a, C, A> {} - -impl<'a, C, A> HttpHealthCheckInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpHealthChecks.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpHealthChecks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: HttpHealthCheck) -> HttpHealthCheckInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpHealthCheckInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpHealthCheckInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpHealthCheckInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpHealthCheckInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates a HttpHealthCheck resource in the specified project using the data included in the request. -/// -/// A builder for the *update* method supported by a *httpHealthCheck* resource. -/// It is not used directly, but through a `HttpHealthCheckMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::HttpHealthCheck; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = HttpHealthCheck::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.http_health_checks().update(req, "project", "httpHealthCheck") -/// .doit(); -/// # } -/// ``` -pub struct HttpHealthCheckUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: HttpHealthCheck, - _project: String, - _http_health_check: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for HttpHealthCheckUpdateCall<'a, C, A> {} - -impl<'a, C, A> HttpHealthCheckUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.httpHealthChecks.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("httpHealthCheck", self._http_health_check.to_string())); - for &field in ["alt", "project", "httpHealthCheck"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/httpHealthChecks/{httpHealthCheck}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{httpHealthCheck}", "httpHealthCheck")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["httpHealthCheck", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: HttpHealthCheck) -> HttpHealthCheckUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> HttpHealthCheckUpdateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the HttpHealthCheck resource to update. - /// - /// Sets the *http health check* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn http_health_check(mut self, new_value: &str) -> HttpHealthCheckUpdateCall<'a, C, A> { - self._http_health_check = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> HttpHealthCheckUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> HttpHealthCheckUpdateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> HttpHealthCheckUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified instance template. If you delete an instance template that is being referenced from another instance group, the instance group will not be able to create or recreate virtual machine instances. Deleting an instance template is permanent and cannot be undone. -/// -/// A builder for the *delete* method supported by a *instanceTemplate* resource. -/// It is not used directly, but through a `InstanceTemplateMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_templates().delete("project", "instanceTemplate") -/// .doit(); -/// # } -/// ``` -pub struct InstanceTemplateDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _instance_template: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceTemplateDeleteCall<'a, C, A> {} - -impl<'a, C, A> InstanceTemplateDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceTemplates.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("instanceTemplate", self._instance_template.to_string())); - for &field in ["alt", "project", "instanceTemplate"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/instanceTemplates/{instanceTemplate}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{instanceTemplate}", "instanceTemplate")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["instanceTemplate", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceTemplateDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the instance template to delete. - /// - /// Sets the *instance template* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_template(mut self, new_value: &str) -> InstanceTemplateDeleteCall<'a, C, A> { - self._instance_template = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceTemplateDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceTemplateDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceTemplateDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified instance template. Get a list of available instance templates by making a list() request. -/// -/// A builder for the *get* method supported by a *instanceTemplate* resource. -/// It is not used directly, but through a `InstanceTemplateMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_templates().get("project", "instanceTemplate") -/// .doit(); -/// # } -/// ``` -pub struct InstanceTemplateGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _instance_template: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceTemplateGetCall<'a, C, A> {} - -impl<'a, C, A> InstanceTemplateGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceTemplate)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceTemplates.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("instanceTemplate", self._instance_template.to_string())); - for &field in ["alt", "project", "instanceTemplate"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/instanceTemplates/{instanceTemplate}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{instanceTemplate}", "instanceTemplate")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["instanceTemplate", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceTemplateGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The name of the instance template. - /// - /// Sets the *instance template* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn instance_template(mut self, new_value: &str) -> InstanceTemplateGetCall<'a, C, A> { - self._instance_template = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceTemplateGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceTemplateGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceTemplateGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of instance templates that are contained within the specified project and zone. -/// -/// A builder for the *list* method supported by a *instanceTemplate* resource. -/// It is not used directly, but through a `InstanceTemplateMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.instance_templates().list("project") -/// .page_token("clita") -/// .max_results(26) -/// .filter("sea") -/// .doit(); -/// # } -/// ``` -pub struct InstanceTemplateListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceTemplateListCall<'a, C, A> {} - -impl<'a, C, A> InstanceTemplateListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, InstanceTemplateList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceTemplates.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/instanceTemplates".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceTemplateListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> InstanceTemplateListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> InstanceTemplateListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> InstanceTemplateListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceTemplateListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceTemplateListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceTemplateListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates an instance template in the specified project using the data that is included in the request. If you are creating a new template to update an existing instance group, your new instance template must use the same network or, if applicable, the same subnetwork as the original template. -/// -/// A builder for the *insert* method supported by a *instanceTemplate* resource. -/// It is not used directly, but through a `InstanceTemplateMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::InstanceTemplate; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = InstanceTemplate::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.instance_templates().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct InstanceTemplateInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: InstanceTemplate, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstanceTemplateInsertCall<'a, C, A> {} - -impl<'a, C, A> InstanceTemplateInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.instanceTemplates.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/instanceTemplates".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: InstanceTemplate) -> InstanceTemplateInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> InstanceTemplateInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceTemplateInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> InstanceTemplateInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> InstanceTemplateInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified TargetHttpProxy resource. -/// -/// A builder for the *delete* method supported by a *targetHttpProxy* resource. -/// It is not used directly, but through a `TargetHttpProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_http_proxies().delete("project", "targetHttpProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpProxyDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _target_http_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpProxyDeleteCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpProxyDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpProxies.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetHttpProxy", self._target_http_proxy.to_string())); - for &field in ["alt", "project", "targetHttpProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpProxies/{targetHttpProxy}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetHttpProxy}", "targetHttpProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetHttpProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpProxyDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetHttpProxy resource to delete. - /// - /// Sets the *target http proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_http_proxy(mut self, new_value: &str) -> TargetHttpProxyDeleteCall<'a, C, A> { - self._target_http_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpProxyDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpProxyDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpProxyDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of TargetHttpProxy resources available to the specified project. -/// -/// A builder for the *list* method supported by a *targetHttpProxy* resource. -/// It is not used directly, but through a `TargetHttpProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_http_proxies().list("project") -/// .page_token("Stet") -/// .max_results(18) -/// .filter("Lorem") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpProxyListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpProxyListCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpProxyListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetHttpProxyList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpProxies.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpProxies".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpProxyListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> TargetHttpProxyListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> TargetHttpProxyListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> TargetHttpProxyListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpProxyListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpProxyListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpProxyListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Changes the URL map for TargetHttpProxy. -/// -/// A builder for the *setUrlMap* method supported by a *targetHttpProxy* resource. -/// It is not used directly, but through a `TargetHttpProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::UrlMapReference; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = UrlMapReference::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.target_http_proxies().set_url_map(req, "project", "targetHttpProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpProxySetUrlMapCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: UrlMapReference, - _project: String, - _target_http_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpProxySetUrlMapCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpProxySetUrlMapCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpProxies.setUrlMap", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetHttpProxy", self._target_http_proxy.to_string())); - for &field in ["alt", "project", "targetHttpProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/targetHttpProxies/{targetHttpProxy}/setUrlMap".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetHttpProxy}", "targetHttpProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetHttpProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: UrlMapReference) -> TargetHttpProxySetUrlMapCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpProxySetUrlMapCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetHttpProxy to set a URL map for. - /// - /// Sets the *target http proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_http_proxy(mut self, new_value: &str) -> TargetHttpProxySetUrlMapCall<'a, C, A> { - self._target_http_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpProxySetUrlMapCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpProxySetUrlMapCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpProxySetUrlMapCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified TargetHttpProxy resource. Get a list of available target HTTP proxies by making a list() request. -/// -/// A builder for the *get* method supported by a *targetHttpProxy* resource. -/// It is not used directly, but through a `TargetHttpProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.target_http_proxies().get("project", "targetHttpProxy") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpProxyGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _target_http_proxy: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpProxyGetCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpProxyGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, TargetHttpProxy)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpProxies.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("targetHttpProxy", self._target_http_proxy.to_string())); - for &field in ["alt", "project", "targetHttpProxy"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpProxies/{targetHttpProxy}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{targetHttpProxy}", "targetHttpProxy")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["targetHttpProxy", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpProxyGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the TargetHttpProxy resource to return. - /// - /// Sets the *target http proxy* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn target_http_proxy(mut self, new_value: &str) -> TargetHttpProxyGetCall<'a, C, A> { - self._target_http_proxy = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpProxyGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpProxyGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpProxyGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a TargetHttpProxy resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *targetHttpProxy* resource. -/// It is not used directly, but through a `TargetHttpProxyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::TargetHttpProxy; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = TargetHttpProxy::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.target_http_proxies().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct TargetHttpProxyInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: TargetHttpProxy, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for TargetHttpProxyInsertCall<'a, C, A> {} - -impl<'a, C, A> TargetHttpProxyInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.targetHttpProxies.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpProxies".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: TargetHttpProxy) -> TargetHttpProxyInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> TargetHttpProxyInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetHttpProxyInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> TargetHttpProxyInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> TargetHttpProxyInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified SslCertificate resource. -/// -/// A builder for the *delete* method supported by a *sslCertificate* resource. -/// It is not used directly, but through a `SslCertificateMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.ssl_certificates().delete("project", "sslCertificate") -/// .doit(); -/// # } -/// ``` -pub struct SslCertificateDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _ssl_certificate: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SslCertificateDeleteCall<'a, C, A> {} - -impl<'a, C, A> SslCertificateDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.sslCertificates.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("sslCertificate", self._ssl_certificate.to_string())); - for &field in ["alt", "project", "sslCertificate"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/sslCertificates/{sslCertificate}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{sslCertificate}", "sslCertificate")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["sslCertificate", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SslCertificateDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the SslCertificate resource to delete. - /// - /// Sets the *ssl certificate* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn ssl_certificate(mut self, new_value: &str) -> SslCertificateDeleteCall<'a, C, A> { - self._ssl_certificate = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SslCertificateDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SslCertificateDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SslCertificateDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of SslCertificate resources available to the specified project. -/// -/// A builder for the *list* method supported by a *sslCertificate* resource. -/// It is not used directly, but through a `SslCertificateMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.ssl_certificates().list("project") -/// .page_token("est") -/// .max_results(13) -/// .filter("accusam") -/// .doit(); -/// # } -/// ``` -pub struct SslCertificateListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SslCertificateListCall<'a, C, A> {} - -impl<'a, C, A> SslCertificateListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SslCertificateList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.sslCertificates.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/sslCertificates".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SslCertificateListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> SslCertificateListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> SslCertificateListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> SslCertificateListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SslCertificateListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SslCertificateListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SslCertificateListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a SslCertificate resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *sslCertificate* resource. -/// It is not used directly, but through a `SslCertificateMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::SslCertificate; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = SslCertificate::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.ssl_certificates().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct SslCertificateInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: SslCertificate, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SslCertificateInsertCall<'a, C, A> {} - -impl<'a, C, A> SslCertificateInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.sslCertificates.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/sslCertificates".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: SslCertificate) -> SslCertificateInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SslCertificateInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SslCertificateInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SslCertificateInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SslCertificateInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified SslCertificate resource. Get a list of available SSL certificates by making a list() request. -/// -/// A builder for the *get* method supported by a *sslCertificate* resource. -/// It is not used directly, but through a `SslCertificateMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.ssl_certificates().get("project", "sslCertificate") -/// .doit(); -/// # } -/// ``` -pub struct SslCertificateGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _ssl_certificate: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SslCertificateGetCall<'a, C, A> {} - -impl<'a, C, A> SslCertificateGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SslCertificate)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.sslCertificates.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("sslCertificate", self._ssl_certificate.to_string())); - for &field in ["alt", "project", "sslCertificate"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/sslCertificates/{sslCertificate}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{sslCertificate}", "sslCertificate")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["sslCertificate", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> SslCertificateGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the SslCertificate resource to return. - /// - /// Sets the *ssl certificate* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn ssl_certificate(mut self, new_value: &str) -> SslCertificateGetCall<'a, C, A> { - self._ssl_certificate = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SslCertificateGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SslCertificateGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SslCertificateGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified zone-specific Operations resource. -/// -/// A builder for the *delete* method supported by a *zoneOperation* resource. -/// It is not used directly, but through a `ZoneOperationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.zone_operations().delete("project", "zone", "operation") -/// .doit(); -/// # } -/// ``` -pub struct ZoneOperationDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _operation: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ZoneOperationDeleteCall<'a, C, A> {} - -impl<'a, C, A> ZoneOperationDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.zoneOperations.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("operation", self._operation.to_string())); - for &field in ["project", "zone", "operation"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{operation}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{operation}", "operation")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["operation", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = res; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ZoneOperationDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> ZoneOperationDeleteCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the Operations resource to delete. - /// - /// Sets the *operation* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn operation(mut self, new_value: &str) -> ZoneOperationDeleteCall<'a, C, A> { - self._operation = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ZoneOperationDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ZoneOperationDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ZoneOperationDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of Operation resources contained within the specified zone. -/// -/// A builder for the *list* method supported by a *zoneOperation* resource. -/// It is not used directly, but through a `ZoneOperationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.zone_operations().list("project", "zone") -/// .page_token("et") -/// .max_results(94) -/// .filter("et") -/// .doit(); -/// # } -/// ``` -pub struct ZoneOperationListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ZoneOperationListCall<'a, C, A> {} - -impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, OperationList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.zoneOperations.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ZoneOperationListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone for request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> ZoneOperationListCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ZoneOperationListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> ZoneOperationListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> ZoneOperationListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ZoneOperationListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ZoneOperationListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ZoneOperationListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the specified zone-specific Operations resource. -/// -/// A builder for the *get* method supported by a *zoneOperation* resource. -/// It is not used directly, but through a `ZoneOperationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.zone_operations().get("project", "zone", "operation") -/// .doit(); -/// # } -/// ``` -pub struct ZoneOperationGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _zone: String, - _operation: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ZoneOperationGetCall<'a, C, A> {} - -impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.zoneOperations.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("zone", self._zone.to_string())); - params.push(("operation", self._operation.to_string())); - for &field in ["alt", "project", "zone", "operation"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{operation}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{operation}", "operation")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["operation", "zone", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> ZoneOperationGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the zone for this request. - /// - /// Sets the *zone* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn zone(mut self, new_value: &str) -> ZoneOperationGetCall<'a, C, A> { - self._zone = new_value.to_string(); - self - } - /// Name of the Operations resource to return. - /// - /// Sets the *operation* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn operation(mut self, new_value: &str) -> ZoneOperationGetCall<'a, C, A> { - self._operation = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ZoneOperationGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ZoneOperationGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ZoneOperationGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified Route resource. Get a list of available routes by making a list() request. -/// -/// A builder for the *get* method supported by a *route* resource. -/// It is not used directly, but through a `RouteMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.routes().get("project", "route") -/// .doit(); -/// # } -/// ``` -pub struct RouteGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _route: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouteGetCall<'a, C, A> {} - -impl<'a, C, A> RouteGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Route)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routes.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("route", self._route.to_string())); - for &field in ["alt", "project", "route"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/routes/{route}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{route}", "route")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["route", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouteGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the Route resource to return. - /// - /// Sets the *route* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn route(mut self, new_value: &str) -> RouteGetCall<'a, C, A> { - self._route = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouteGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouteGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouteGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a Route resource in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *route* resource. -/// It is not used directly, but through a `RouteMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Route; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Route::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.routes().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct RouteInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Route, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouteInsertCall<'a, C, A> {} - -impl<'a, C, A> RouteInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routes.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/routes".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Route) -> RouteInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouteInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouteInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouteInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouteInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of Route resources available to the specified project. -/// -/// A builder for the *list* method supported by a *route* resource. -/// It is not used directly, but through a `RouteMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.routes().list("project") -/// .page_token("sit") -/// .max_results(1) -/// .filter("clita") -/// .doit(); -/// # } -/// ``` -pub struct RouteListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouteListCall<'a, C, A> {} - -impl<'a, C, A> RouteListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, RouteList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routes.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/routes".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouteListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> RouteListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> RouteListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> RouteListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouteListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouteListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouteListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified Route resource. -/// -/// A builder for the *delete* method supported by a *route* resource. -/// It is not used directly, but through a `RouteMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.routes().delete("project", "route") -/// .doit(); -/// # } -/// ``` -pub struct RouteDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _route: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RouteDeleteCall<'a, C, A> {} - -impl<'a, C, A> RouteDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.routes.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("route", self._route.to_string())); - for &field in ["alt", "project", "route"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/routes/{route}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{route}", "route")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["route", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RouteDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the Route resource to delete. - /// - /// Sets the *route* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn route(mut self, new_value: &str) -> RouteDeleteCall<'a, C, A> { - self._route = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RouteDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RouteDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RouteDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates the specified firewall rule with the data included in the request. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *firewall* resource. -/// It is not used directly, but through a `FirewallMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Firewall; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Firewall::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.firewalls().patch(req, "project", "firewall") -/// .doit(); -/// # } -/// ``` -pub struct FirewallPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Firewall, - _project: String, - _firewall: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for FirewallPatchCall<'a, C, A> {} - -impl<'a, C, A> FirewallPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.firewalls.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("firewall", self._firewall.to_string())); - for &field in ["alt", "project", "firewall"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/firewalls/{firewall}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{firewall}", "firewall")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["firewall", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Firewall) -> FirewallPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> FirewallPatchCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the firewall rule to update. - /// - /// Sets the *firewall* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn firewall(mut self, new_value: &str) -> FirewallPatchCall<'a, C, A> { - self._firewall = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> FirewallPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> FirewallPatchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> FirewallPatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified firewall. -/// -/// A builder for the *get* method supported by a *firewall* resource. -/// It is not used directly, but through a `FirewallMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.firewalls().get("project", "firewall") -/// .doit(); -/// # } -/// ``` -pub struct FirewallGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _firewall: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for FirewallGetCall<'a, C, A> {} - -impl<'a, C, A> FirewallGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Firewall)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.firewalls.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("firewall", self._firewall.to_string())); - for &field in ["alt", "project", "firewall"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/firewalls/{firewall}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{firewall}", "firewall")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["firewall", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> FirewallGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the firewall rule to return. - /// - /// Sets the *firewall* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn firewall(mut self, new_value: &str) -> FirewallGetCall<'a, C, A> { - self._firewall = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> FirewallGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> FirewallGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> FirewallGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates the specified firewall rule with the data included in the request. -/// -/// A builder for the *update* method supported by a *firewall* resource. -/// It is not used directly, but through a `FirewallMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Firewall; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Firewall::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.firewalls().update(req, "project", "firewall") -/// .doit(); -/// # } -/// ``` -pub struct FirewallUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Firewall, - _project: String, - _firewall: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for FirewallUpdateCall<'a, C, A> {} - -impl<'a, C, A> FirewallUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.firewalls.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("firewall", self._firewall.to_string())); - for &field in ["alt", "project", "firewall"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/firewalls/{firewall}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{firewall}", "firewall")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["firewall", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Firewall) -> FirewallUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> FirewallUpdateCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the firewall rule to update. - /// - /// Sets the *firewall* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn firewall(mut self, new_value: &str) -> FirewallUpdateCall<'a, C, A> { - self._firewall = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> FirewallUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> FirewallUpdateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> FirewallUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a firewall rule in the specified project using the data included in the request. -/// -/// A builder for the *insert* method supported by a *firewall* resource. -/// It is not used directly, but through a `FirewallMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::Firewall; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = Firewall::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.firewalls().insert(req, "project") -/// .doit(); -/// # } -/// ``` -pub struct FirewallInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: Firewall, - _project: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for FirewallInsertCall<'a, C, A> {} - -impl<'a, C, A> FirewallInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.firewalls.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - for &field in ["alt", "project"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/firewalls".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Firewall) -> FirewallInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> FirewallInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> FirewallInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> FirewallInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> FirewallInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the list of firewall rules available to the specified project. -/// -/// A builder for the *list* method supported by a *firewall* resource. -/// It is not used directly, but through a `FirewallMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.firewalls().list("project") -/// .page_token("erat") -/// .max_results(68) -/// .filter("dolore") -/// .doit(); -/// # } -/// ``` -pub struct FirewallListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for FirewallListCall<'a, C, A> {} - -impl<'a, C, A> FirewallListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, FirewallList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.firewalls.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/firewalls".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> FirewallListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> FirewallListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> FirewallListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> FirewallListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> FirewallListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> FirewallListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> FirewallListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified firewall. -/// -/// A builder for the *delete* method supported by a *firewall* resource. -/// It is not used directly, but through a `FirewallMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.firewalls().delete("project", "firewall") -/// .doit(); -/// # } -/// ``` -pub struct FirewallDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _firewall: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for FirewallDeleteCall<'a, C, A> {} - -impl<'a, C, A> FirewallDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.firewalls.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("firewall", self._firewall.to_string())); - for &field in ["alt", "project", "firewall"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/firewalls/{firewall}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{firewall}", "firewall")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["firewall", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> FirewallDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the firewall rule to delete. - /// - /// Sets the *firewall* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn firewall(mut self, new_value: &str) -> FirewallDeleteCall<'a, C, A> { - self._firewall = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> FirewallDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> FirewallDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> FirewallDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a VpnTunnel resource in the specified project and region using the data included in the request. -/// -/// A builder for the *insert* method supported by a *vpnTunnel* resource. -/// It is not used directly, but through a `VpnTunnelMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// use compute1::VpnTunnel; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), 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 = VpnTunnel::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.vpn_tunnels().insert(req, "project", "region") -/// .doit(); -/// # } -/// ``` -pub struct VpnTunnelInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _request: VpnTunnel, - _project: String, - _region: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for VpnTunnelInsertCall<'a, C, A> {} - -impl<'a, C, A> VpnTunnelInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.vpnTunnels.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - for &field in ["alt", "project", "region"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/vpnTunnels".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: VpnTunnel) -> VpnTunnelInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> VpnTunnelInsertCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> VpnTunnelInsertCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> VpnTunnelInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> VpnTunnelInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> VpnTunnelInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified VpnTunnel resource. -/// -/// A builder for the *delete* method supported by a *vpnTunnel* resource. -/// It is not used directly, but through a `VpnTunnelMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.vpn_tunnels().delete("project", "region", "vpnTunnel") -/// .doit(); -/// # } -/// ``` -pub struct VpnTunnelDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _vpn_tunnel: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for VpnTunnelDeleteCall<'a, C, A> {} - -impl<'a, C, A> VpnTunnelDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.vpnTunnels.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("vpnTunnel", self._vpn_tunnel.to_string())); - for &field in ["alt", "project", "region", "vpnTunnel"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/vpnTunnels/{vpnTunnel}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{vpnTunnel}", "vpnTunnel")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["vpnTunnel", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> VpnTunnelDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> VpnTunnelDeleteCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the VpnTunnel resource to delete. - /// - /// Sets the *vpn tunnel* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn vpn_tunnel(mut self, new_value: &str) -> VpnTunnelDeleteCall<'a, C, A> { - self._vpn_tunnel = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> VpnTunnelDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> VpnTunnelDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> VpnTunnelDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the specified VpnTunnel resource. Get a list of available VPN tunnels by making a list() request. -/// -/// A builder for the *get* method supported by a *vpnTunnel* resource. -/// It is not used directly, but through a `VpnTunnelMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.vpn_tunnels().get("project", "region", "vpnTunnel") -/// .doit(); -/// # } -/// ``` -pub struct VpnTunnelGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _vpn_tunnel: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for VpnTunnelGetCall<'a, C, A> {} - -impl<'a, C, A> VpnTunnelGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, VpnTunnel)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.vpnTunnels.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("vpnTunnel", self._vpn_tunnel.to_string())); - for &field in ["alt", "project", "region", "vpnTunnel"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/vpnTunnels/{vpnTunnel}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{vpnTunnel}", "vpnTunnel")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["vpnTunnel", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> VpnTunnelGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> VpnTunnelGetCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the VpnTunnel resource to return. - /// - /// Sets the *vpn tunnel* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn vpn_tunnel(mut self, new_value: &str) -> VpnTunnelGetCall<'a, C, A> { - self._vpn_tunnel = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> VpnTunnelGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> VpnTunnelGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> VpnTunnelGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves an aggregated list of VPN tunnels. -/// -/// A builder for the *aggregatedList* method supported by a *vpnTunnel* resource. -/// It is not used directly, but through a `VpnTunnelMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.vpn_tunnels().aggregated_list("project") -/// .page_token("tempor") -/// .max_results(9) -/// .filter("takimata") -/// .doit(); -/// # } -/// ``` -pub struct VpnTunnelAggregatedListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for VpnTunnelAggregatedListCall<'a, C, A> {} - -impl<'a, C, A> VpnTunnelAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, VpnTunnelAggregatedList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.vpnTunnels.aggregatedList", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/aggregated/vpnTunnels".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> VpnTunnelAggregatedListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> VpnTunnelAggregatedListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> VpnTunnelAggregatedListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> VpnTunnelAggregatedListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> VpnTunnelAggregatedListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> VpnTunnelAggregatedListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> VpnTunnelAggregatedListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of VpnTunnel resources contained in the specified project and region. -/// -/// A builder for the *list* method supported by a *vpnTunnel* resource. -/// It is not used directly, but through a `VpnTunnelMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.vpn_tunnels().list("project", "region") -/// .page_token("amet.") -/// .max_results(72) -/// .filter("sea") -/// .doit(); -/// # } -/// ``` -pub struct VpnTunnelListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for VpnTunnelListCall<'a, C, A> {} - -impl<'a, C, A> VpnTunnelListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, VpnTunnelList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.vpnTunnels.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "region", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/vpnTunnels".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> VpnTunnelListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> VpnTunnelListCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> VpnTunnelListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> VpnTunnelListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> VpnTunnelListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> VpnTunnelListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> VpnTunnelListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> VpnTunnelListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a list of Operation resources contained within the specified region. -/// -/// A builder for the *list* method supported by a *regionOperation* resource. -/// It is not used directly, but through a `RegionOperationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.region_operations().list("project", "region") -/// .page_token("voluptua.") -/// .max_results(24) -/// .filter("sanctus") -/// .doit(); -/// # } -/// ``` -pub struct RegionOperationListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _page_token: Option, - _max_results: Option, - _filter: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RegionOperationListCall<'a, C, A> {} - -impl<'a, C, A> RegionOperationListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, OperationList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.regionOperations.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._filter { - params.push(("filter", value.to_string())); - } - for &field in ["alt", "project", "region", "pageToken", "maxResults", "filter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RegionOperationListCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RegionOperationListCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> RegionOperationListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> RegionOperationListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. - /// - /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. - /// - /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. - /// - /// You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. - /// - /// To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. - /// - /// Sets the *filter* query property to the given value. - pub fn filter(mut self, new_value: &str) -> RegionOperationListCall<'a, C, A> { - self._filter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RegionOperationListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RegionOperationListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RegionOperationListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes the specified region-specific Operations resource. -/// -/// A builder for the *delete* method supported by a *regionOperation* resource. -/// It is not used directly, but through a `RegionOperationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.region_operations().delete("project", "region", "operation") -/// .doit(); -/// # } -/// ``` -pub struct RegionOperationDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _operation: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RegionOperationDeleteCall<'a, C, A> {} - -impl<'a, C, A> RegionOperationDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.regionOperations.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("operation", self._operation.to_string())); - for &field in ["project", "region", "operation"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{operation}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{operation}", "operation")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["operation", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = res; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RegionOperationDeleteCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RegionOperationDeleteCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the Operations resource to delete. - /// - /// Sets the *operation* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn operation(mut self, new_value: &str) -> RegionOperationDeleteCall<'a, C, A> { - self._operation = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RegionOperationDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RegionOperationDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RegionOperationDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the specified region-specific Operations resource. -/// -/// A builder for the *get* method supported by a *regionOperation* resource. -/// It is not used directly, but through a `RegionOperationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_compute1 as compute1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use compute1::Compute; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Compute::new(hyper::Client::new(), auth); -/// // 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.region_operations().get("project", "region", "operation") -/// .doit(); -/// # } -/// ``` -pub struct RegionOperationGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Compute, - _project: String, - _region: String, - _operation: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for RegionOperationGetCall<'a, C, A> {} - -impl<'a, C, A> RegionOperationGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "compute.regionOperations.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("project", self._project.to_string())); - params.push(("region", self._region.to_string())); - params.push(("operation", self._operation.to_string())); - for &field in ["alt", "project", "region", "operation"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{operation}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{project}", "project"), ("{region}", "region"), ("{operation}", "operation")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["operation", "region", "project"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Project ID for this request. - /// - /// Sets the *project* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project(mut self, new_value: &str) -> RegionOperationGetCall<'a, C, A> { - self._project = new_value.to_string(); - self - } - /// Name of the region for this request. - /// - /// Sets the *region* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn region(mut self, new_value: &str) -> RegionOperationGetCall<'a, C, A> { - self._region = new_value.to_string(); - self - } - /// Name of the Operations resource to return. - /// - /// Sets the *operation* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn operation(mut self, new_value: &str) -> RegionOperationGetCall<'a, C, A> { - self._operation = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> RegionOperationGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> RegionOperationGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> RegionOperationGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - diff --git a/gen/consumersurveys2-cli/Cargo.toml b/gen/consumersurveys2-cli/Cargo.toml deleted file mode 100644 index c346fcc163..0000000000 --- a/gen/consumersurveys2-cli/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-consumersurveys2-cli" -version = "0.3.5+20160405" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with consumersurveys (protocol v2)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/consumersurveys2-cli" -documentation = "http://byron.github.io/google-apis-rs/google_consumersurveys2_cli" -license = "MIT" -keywords = ["consumersurveys", "google", "cli"] - -[[bin]] -name = "consumersurveys2" - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -strsim = "^0.4" -yup-hyper-mock = "^1.0" -clap = "^2.0" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-consumersurveys2/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-consumersurveys2/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - - -[dependencies.google-consumersurveys2] -path = "../consumersurveys2" -optional = true -default-features = false diff --git a/gen/consumersurveys2-cli/LICENSE.md b/gen/consumersurveys2-cli/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/consumersurveys2-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/consumersurveys2-cli/README.md b/gen/consumersurveys2-cli/README.md deleted file mode 100644 index 133fc10a24..0000000000 --- a/gen/consumersurveys2-cli/README.md +++ /dev/null @@ -1,117 +0,0 @@ - -The `consumersurveys2` command-line interface *(CLI)* allows to use most features of the *Google consumersurveys* service from the comfort of your terminal. - -By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's -capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. - -If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. - -# Downloads - -You can download the pre-compiled 64bit binaries for the following platforms: - -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.5/ubuntu/consumersurveys2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.5/osx/consumersurveys2.tar.gz) - -Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/consumersurveys2-cli). - -# Usage - -This documentation was generated from the *consumersurveys* API at revision *20160405*. The CLI is at version *0.3.5*. - -```bash -consumersurveys2 [options] - results - get (-r )... [-p ]... [-o ] - surveys - get [-p ]... [-o ] - insert (-r )... [-p ]... [-o ] - list [-p ]... [-o ] - start [-p ]... [-o ] - stop [-p ]... [-o ] - update (-r )... [-p ]... [-o ] - consumersurveys2 --help - -Configuration: - [--scope ]... - Specify the authentication a method should be executed in. Each scope - requires the user to grant this application permission to use it. - If unset, it defaults to the shortest scope url for a particular method. - --config-dir - A directory into which we will store our persistent data. Defaults to - a user-writable directory that we will create during the first invocation. - [default: ~/.google-service-cli] - --debug - Output all server communication to standard error. `tx` and `rx` are placed - into the same stream. - --debug-auth - Output all communication related to authentication to standard error. `tx` - and `rx` are placed into the same stream. - -``` - -# Configuration - -The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `consumersurveys2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. - -More information about the various kinds of persistent data are given in the following paragraphs. - -# Authentication - -Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the -set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. - -If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a -method that is read-only, it will ask only for a read-only scope. -You may use the `--scope` flag to specify a scope directly. -All applicable scopes are documented in the respective method's CLI documentation. - -The first time a scope is used, the user is asked for permission. Follow the instructions given -by the CLI to grant permissions, or to decline. - -If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration -directory, e.g. `~/.google-service-cli/consumersurveys2-token-.json`. No manual management of these tokens -is necessary. - -To revoke granted authentication, please refer to the [official documentation][revoke-access]. - -# Application Secrets - -In order to allow any application to use Google services, it will need to be registered using the -[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it -one by one. Most APIs can be used for free and have a daily quota. - -To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI -comes with a default application secret that is configured accordingly. This also means that heavy usage -all around the world may deplete the daily quota. - -You can workaround this limitation by putting your own secrets file at this location: -`~/.google-service-cli/consumersurveys2-secret.json`, assuming that the required *consumersurveys* API -was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at -*APIs & auth -> Credentials -> Download JSON* and used as is. - -Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. - - -# Debugging - -Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know -what exactly led to a particular issue. This is done by allowing all client-server communication to be -output to standard error *as-is*. - -The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag -will cause all communication related to authentication to standard error. -If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the -issue at hand. - -You may consider redirecting standard error into a file for ease of use, e.g. `consumersurveys2 --debug [options] 2>debug.txt`. - - -[scopes]: https://developers.google.com/+/api/oauth#scopes -[revoke-access]: http://webapps.stackexchange.com/a/30849 -[google-dev-console]: https://console.developers.google.com/ -[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/consumersurveys2-cli/mkdocs.yml b/gen/consumersurveys2-cli/mkdocs.yml deleted file mode 100644 index d56bd842c1..0000000000 --- a/gen/consumersurveys2-cli/mkdocs.yml +++ /dev/null @@ -1,23 +0,0 @@ -site_name: consumersurveys v0.3.5+20160405 -site_url: http://byron.github.io/google-apis-rs/google-consumersurveys2-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/consumersurveys2-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['results_get.md', 'Results', 'Get'] -- ['surveys_get.md', 'Surveys', 'Get'] -- ['surveys_insert.md', 'Surveys', 'Insert'] -- ['surveys_list.md', 'Surveys', 'List'] -- ['surveys_start.md', 'Surveys', 'Start'] -- ['surveys_stop.md', 'Surveys', 'Stop'] -- ['surveys_update.md', 'Surveys', 'Update'] - -theme: readthedocs - -copyright: Copyright © 2015-2016, `Sebastian Thiel` - diff --git a/gen/consumersurveys2-cli/src/cmn.rs b/gen/consumersurveys2-cli/src/cmn.rs deleted file mode 100644 index 779c1dc086..0000000000 --- a/gen/consumersurveys2-cli/src/cmn.rs +++ /dev/null @@ -1,721 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use serde_json as json; -use serde_json::value::Value; -use mime::Mime; -use clap::{App, SubCommand}; -use strsim; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - - -pub enum ComplexType { - Pod, - Vec, - Map, -} - - // Null, - // Bool(bool), - // I64(i64), - // U64(u64), - // F64(f64), - // String(String), - -pub enum JsonType { - Boolean, - Int, - Uint, - Float, - String, -} - -pub struct JsonTypeInfo { - pub jtype: JsonType, - pub ctype: ComplexType, -} - -// Based on @erickt user comment. Thanks for the idea ! -// Remove all keys whose values are null from given value (changed in place) -pub fn remove_json_null_values(value: &mut Value) { - match *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); - } - } - _ => {} - } -} - -fn did_you_mean<'a>(v: &str, possible_values: &[&'a str]) -> Option<&'a str> { - - let mut candidate: Option<(f64, &str)> = None; - for pv in possible_values { - let confidence = strsim::jaro_winkler(v, pv); - if confidence > 0.8 && (candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence)) { - candidate = Some((confidence, pv)); - } - } - match candidate { - None => None, - Some((_, candidate)) => Some(candidate), - } -} - -pub enum CallType { - Upload(UploadProtocol), - Standard, -} - -arg_enum!{ - pub enum UploadProtocol { - Simple, - Resumable - } -} - -impl AsRef for UploadProtocol { - fn as_ref(&self) -> &str { - match *self { - UploadProtocol::Simple => "simple", - UploadProtocol::Resumable => "resumable" - } - } -} - -impl AsRef for CallType { - fn as_ref(&self) -> &str { - match *self { - CallType::Upload(ref proto) => proto.as_ref(), - CallType::Standard => "standard-request" - } - } -} - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.join(".") - } -} - -impl From<&'static str> for FieldCursor { - fn from(value: &'static str) -> FieldCursor { - let mut res = FieldCursor::default(); - res.set(value).unwrap(); - res - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn did_you_mean(value: &str, possible_values: &[&str]) -> Option { - if value.len() == 0 { - return None - } - - let mut last_c = FIELD_SEP; - - let mut field = String::new(); - let mut output = String::new(); - - let push_field = |fs: &mut String, f: &mut String| { - if f.len() > 0 { - fs.push_str( - match did_you_mean(&f, possible_values) { - Some(candidate) => candidate, - None => &f, - }); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - if c == FIELD_SEP { - if last_c != FIELD_SEP { - push_field(&mut output, &mut field); - } - output.push(c); - } else { - field.push(c); - } - - last_c = c; - } - - push_field(&mut output, &mut field); - - if &output == value { - None - } else { - Some(output) - } - } - - pub fn set_json_value(&self, mut object: &mut Value, - value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, - orig_cursor: &FieldCursor) { - assert!(self.0.len() > 0); - - for field in &self.0[..self.0.len()-1] { - let tmp = object; - object = - match *tmp { - Value::Object(ref mut mapping) => { - mapping.entry(field.to_owned()).or_insert( - Value::Object(Default::default()) - ) - }, - _ => panic!("We don't expect non-object Values here ...") - }; - } - - match *object { - Value::Object(ref mut mapping) => { - let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| - -> Value { - match jtype { - JsonType::Boolean => - Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => - Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => - Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => - Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => - Value::String(value.to_owned()), - } - }; - - match type_info.ctype { - ComplexType::Pod => { - if mapping.insert(field.to_owned(), to_jval(value, type_info.jtype, err)).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - }, - ComplexType::Vec => { - match *mapping.entry(field.to_owned()) - .or_insert(Value::Array(Default::default())) { - Value::Array(ref mut values) => values.push(to_jval(value, type_info.jtype, err)), - _ => unreachable!() - } - }, - ComplexType::Map => { - let (key, value) = parse_kv_arg(value, err, true); - let jval = to_jval(value.unwrap_or(""), type_info.jtype, err); - - match *mapping.entry(field.to_owned()) - .or_insert(Value::Object(Default::default())) { - Value::Object(ref mut value_map) => { - if value_map.insert(key.to_owned(), jval).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - } - _ => unreachable!() - } - } - } - }, - _ => unreachable!() - } - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); - match kv.find('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, Some("")) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut InvalidOptionsError) -> CallType { - CallType::Upload( - match UploadProtocol::from_str(name) { - Ok(up) => up, - Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); - UploadProtocol::Simple - } - }) -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::Io((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { - let f = arg.unwrap_or("-"); - match f { - "-" => Ok(Box::new(stdout())), - _ => match fs::OpenOptions::new().create(true).write(true).open(f) { - Ok(f) => Ok(Box::new(f)), - Err(io_err) => Err(io_err), - } - } -} - - -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, - arg_type: &'a str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError(arg_name.to_owned(), arg_type.to_owned(), arg.to_string(), format!("{}", perr)) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - type Error = json::Error; - - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Result<(), json::Error> { - match token { - None => { - match fs::remove_file(self.path(scope_hash)) { - Err(err) => - match err.kind() { - io::ErrorKind::NotFound => Ok(()), - _ => Err(json::Error::Io(err)) - }, - Ok(_) => Ok(()), - } - } - Some(token) => { - match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { - Ok(mut f) => { - match json::to_writer_pretty(&mut f, &token) { - Ok(_) => Ok(()), - Err(serde_err) => Err(serde_err), - } - }, - Err(io_err) => Err(json::Error::Io(io_err)) - } - } - } - } - - fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, json::Error> { - match fs::File::open(&self.path(scope_hash)) { - Ok(f) => { - match json::de::from_reader(f) { - Ok(token) => Ok(Some(token)), - Err(err) => Err(err), - } - }, - Err(io_err) => { - match io_err.kind() { - io::ErrorKind::NotFound => Ok(None), - _ => Err(json::Error::Io(io_err)) - } - } - } - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::Error)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - Io((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty."), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::Io((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}.", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - Io((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::Io((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}.", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type.", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String, Option, Option), - Duplicate(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor.", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character.", field), - FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = - match *suggestion { - Some(ref s) => { - let kv = - match *value { - Some(ref v) => format!("{}={}", s, v), - None => s.clone(), - }; - format!(" Did you mean '{}' ?", kv) - }, - None => String::new(), - }; - writeln!(f, "Field '{}' does not exist.{}", field, suffix) - }, - FieldError::Duplicate(ref cursor) - => writeln!(f, "Value at '{}' was already set", cursor), - FieldError::Empty - => writeln!(f, "Field names must not be empty."), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError(String, String, String, String), - UnknownParameter(String, Vec<&'static str>), - InvalidUploadProtocol(String, Vec), - InvalidKeyValueSyntax(String, bool), - Input(InputError), - Field(FieldError), - MissingCommandError, - MissingMethodError(String), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let suffix = - match did_you_mean(param_name, &possible_values) { - Some(v) => format!(" Did you mean '{}' ?", v), - None => String::new(), - }; - write!(f, "Parameter '{}' is unknown.{}\n", param_name, suffix) - }, - CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { - let hashmap_info = if is_hashmap { "hashmap " } else { "" }; - writeln!(f, "'{}' does not match {}pattern =.", kv, hashmap_info) - }, - CLIError::MissingCommandError => writeln!(f, "Please specify the main sub-command."), - CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the '{}' command.", cmd), - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, - json_console_secret: &str) - -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::Io( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret - = json::from_str(json_console_secret).unwrap(); - match json::to_writer_pretty(&mut f, &console_secret) { - Err(serde_err) => match serde_err { - json::Error::Io(err) => err, - _ => panic!("Unexpected serde error: {:#?}", serde_err) - }, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(f) => { - match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::Io(err)) => - return secret_io_error(err), - Err(json_err) => - return Err(CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::DecoderError( - (secret_str(), json_err) - )))), - Ok(console_secret) => - match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} diff --git a/gen/consumersurveys2-cli/src/main.rs b/gen/consumersurveys2-cli/src/main.rs deleted file mode 100644 index e0e48602f2..0000000000 --- a/gen/consumersurveys2-cli/src/main.rs +++ /dev/null @@ -1,945 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -#[macro_use] -extern crate clap; -extern crate yup_oauth2 as oauth2; -extern crate yup_hyper_mock as mock; -extern crate serde; -extern crate serde_json; -extern crate hyper; -extern crate mime; -extern crate strsim; -extern crate google_consumersurveys2 as api; - -use std::env; -use std::io::{self, Write}; -use clap::{App, SubCommand, Arg}; - -mod cmn; - -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol, - calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, FlowType}; -use serde_json as json; -use clap::ArgMatches; - -enum DoitError { - IoError(String, io::Error), - ApiError(api::Error), -} - -struct Engine<'n> { - opt: ArgMatches<'n>, - hub: api::Consumersurveys>, - gp: Vec<&'static str>, - gpm: Vec<(&'static str, &'static str)>, -} - - -impl<'n> Engine<'n> { - fn _results_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "result-mask.projection" => Some(("resultMask.projection", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["projection", "result-mask"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::ResultsGetRequest = json::value::from_value(object).unwrap(); - let mut download_mode = false; - let mut call = self.hub.results().get(request, opt.value_of("survey-url-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - if key == "alt" && value.unwrap_or("unset") == "media" { - download_mode = true; - } - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - if !download_mode { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - } else { - io::copy(&mut response, &mut ostream).unwrap(); - ostream.flush().unwrap(); - } - Ok(()) - } - } - } - } - - fn _surveys_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.surveys().get(opt.value_of("survey-url-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _surveys_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "owners" => Some(("owners", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "title" => Some(("title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "customer-data" => Some(("customerData", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "audience.country-subdivision" => Some(("audience.countrySubdivision", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "audience.country" => Some(("audience.country", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "audience.ages" => Some(("audience.ages", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "audience.population-source" => Some(("audience.populationSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "audience.languages" => Some(("audience.languages", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "audience.gender" => Some(("audience.gender", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "cost.nanos" => Some(("cost.nanos", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "cost.currency-code" => Some(("cost.currencyCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "survey-url-id" => Some(("surveyUrlId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "wanted-response-count" => Some(("wantedResponseCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["ages", "audience", "cost", "country", "country-subdivision", "currency-code", "customer-data", "description", "gender", "languages", "nanos", "owners", "population-source", "state", "survey-url-id", "title", "wanted-response-count"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Survey = json::value::from_value(object).unwrap(); - let mut call = self.hub.surveys().insert(request); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _surveys_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.surveys().list(); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "token" => { - call = call.token(value.unwrap_or("")); - }, - "start-index" => { - call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["token", "start-index", "max-results"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _surveys_start(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.surveys().start(opt.value_of("resource-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _surveys_stop(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.surveys().stop(opt.value_of("resource-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _surveys_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "owners" => Some(("owners", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "title" => Some(("title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "customer-data" => Some(("customerData", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "audience.country-subdivision" => Some(("audience.countrySubdivision", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "audience.country" => Some(("audience.country", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "audience.ages" => Some(("audience.ages", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "audience.population-source" => Some(("audience.populationSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "audience.languages" => Some(("audience.languages", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "audience.gender" => Some(("audience.gender", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "cost.nanos" => Some(("cost.nanos", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "cost.currency-code" => Some(("cost.currencyCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "survey-url-id" => Some(("surveyUrlId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "wanted-response-count" => Some(("wantedResponseCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["ages", "audience", "cost", "country", "country-subdivision", "currency-code", "customer-data", "description", "gender", "languages", "nanos", "owners", "population-source", "state", "survey-url-id", "title", "wanted-response-count"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Survey = json::value::from_value(object).unwrap(); - let mut call = self.hub.surveys().update(request, opt.value_of("survey-url-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _doit(&self, dry_run: bool) -> Result, Option> { - let mut err = InvalidOptionsError::new(); - let mut call_result: Result<(), DoitError> = Ok(()); - let mut err_opt: Option = None; - match self.opt.subcommand() { - ("results", Some(opt)) => { - match opt.subcommand() { - ("get", Some(opt)) => { - call_result = self._results_get(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("results".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("surveys", Some(opt)) => { - match opt.subcommand() { - ("get", Some(opt)) => { - call_result = self._surveys_get(opt, dry_run, &mut err); - }, - ("insert", Some(opt)) => { - call_result = self._surveys_insert(opt, dry_run, &mut err); - }, - ("list", Some(opt)) => { - call_result = self._surveys_list(opt, dry_run, &mut err); - }, - ("start", Some(opt)) => { - call_result = self._surveys_start(opt, dry_run, &mut err); - }, - ("stop", Some(opt)) => { - call_result = self._surveys_stop(opt, dry_run, &mut err); - }, - ("update", Some(opt)) => { - call_result = self._surveys_update(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("surveys".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - _ => { - err.issues.push(CLIError::MissingCommandError); - writeln!(io::stderr(), "{}\n", self.opt.usage()).ok(); - } - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - Err(err_opt) - } else { - Ok(call_result) - } - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: ArgMatches<'n>) -> Result, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "consumersurveys2-secret.json", - "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, - if opt.is_present("debug-auth") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }, - JsonTokenStorage { - program_name: "consumersurveys2", - db_dir: config_dir.clone(), - }, Some(FlowType::InstalledInteractive)); - - let client = - if opt.is_present("debug") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }; - let engine = Engine { - opt: opt, - hub: api::Consumersurveys::new(client, auth), - gp: vec!["alt", "fields", "key", "oauth-token", "pretty-print", "quota-user", "user-ip"], - gpm: vec![ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ] - }; - - match engine._doit(true) { - Err(Some(err)) => Err(err), - Err(None) => Ok(engine), - Ok(_) => unreachable!(), - } - } - - fn doit(&self) -> Result<(), DoitError> { - match self._doit(false) { - Ok(res) => res, - Err(_) => unreachable!(), - } - } -} - -fn main() { - let mut exit_status = 0i32; - let arg_data = [ - ("results", "methods: 'get'", vec![ - ("get", - Some(r##"Retrieves any survey results that have been produced so far. Results are formatted as an Excel file."##), - "Details at http://byron.github.io/google-apis-rs/google_consumersurveys2_cli/results_get", - vec![ - (Some(r##"survey-url-id"##), - None, - Some(r##"External URL ID for the survey."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("surveys", "methods: 'get', 'insert', 'list', 'start', 'stop' and 'update'", vec![ - ("get", - Some(r##"Retrieves information about the specified survey."##), - "Details at http://byron.github.io/google-apis-rs/google_consumersurveys2_cli/surveys_get", - vec![ - (Some(r##"survey-url-id"##), - None, - Some(r##"External URL ID for the survey."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("insert", - Some(r##"Creates a survey."##), - "Details at http://byron.github.io/google-apis-rs/google_consumersurveys2_cli/surveys_insert", - vec![ - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("list", - Some(r##"Lists the surveys owned by the authenticated user."##), - "Details at http://byron.github.io/google-apis-rs/google_consumersurveys2_cli/surveys_list", - vec![ - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("start", - Some(r##"Begins running a survey."##), - "Details at http://byron.github.io/google-apis-rs/google_consumersurveys2_cli/surveys_start", - vec![ - (Some(r##"resource-id"##), - None, - None, - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("stop", - Some(r##"Stops a running survey."##), - "Details at http://byron.github.io/google-apis-rs/google_consumersurveys2_cli/surveys_stop", - vec![ - (Some(r##"resource-id"##), - None, - None, - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("update", - Some(r##"Updates a survey. Currently the only property that can be updated is the owners property."##), - "Details at http://byron.github.io/google-apis-rs/google_consumersurveys2_cli/surveys_update", - vec![ - (Some(r##"survey-url-id"##), - None, - Some(r##"External URL ID for the survey."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ]; - - let mut app = App::new("consumersurveys2") - .author("Sebastian Thiel ") - .version("0.3.5+20160405") - .about("API for Google Consumer Surveys.") - .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_consumersurveys2_cli") - .arg(Arg::with_name("url") - .long("scope") - .help("Specify the authentication a method should be executed in. Each scope requires the user to grant this application permission to use it.If unset, it defaults to the shortest scope url for a particular method.") - .multiple(true) - .takes_value(true)) - .arg(Arg::with_name("folder") - .long("config-dir") - .help("A directory into which we will store our persistent data. Defaults to a user-writable directory that we will create during the first invocation.[default: ~/.google-service-cli") - .multiple(false) - .takes_value(true)) - .arg(Arg::with_name("debug") - .long("debug") - .help("Output all server communication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)) - .arg(Arg::with_name("debug-auth") - .long("debug-auth") - .help("Output all communication related to authentication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)); - - for &(main_command_name, about, ref subcommands) in arg_data.iter() { - let mut mcmd = SubCommand::with_name(main_command_name).about(about); - - for &(sub_command_name, ref desc, url_info, ref args) in subcommands { - let mut scmd = SubCommand::with_name(sub_command_name); - if let &Some(desc) = desc { - scmd = scmd.about(desc); - } - scmd = scmd.after_help(url_info); - - for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args { - let arg_name_str = - match (arg_name, flag) { - (&Some(an), _ ) => an, - (_ , &Some(f)) => f, - _ => unreachable!(), - }; - let mut arg = Arg::with_name(arg_name_str) - .empty_values(false); - if let &Some(short_flag) = flag { - arg = arg.short(short_flag); - } - if let &Some(desc) = desc { - arg = arg.help(desc); - } - if arg_name.is_some() && flag.is_some() { - arg = arg.takes_value(true); - } - if let &Some(required) = required { - arg = arg.required(required); - } - if let &Some(multi) = multi { - arg = arg.multiple(multi); - } - scmd = scmd.arg(arg); - } - mcmd = mcmd.subcommand(scmd); - } - app = app.subcommand(mcmd); - } - - let matches = app.get_matches(); - - let debug = matches.is_present("debug"); - match Engine::new(matches) { - Err(err) => { - exit_status = err.exit_code; - writeln!(io::stderr(), "{}", err).ok(); - }, - Ok(engine) => { - if let Err(doit_err) = engine.doit() { - exit_status = 1; - match doit_err { - DoitError::IoError(path, err) => { - writeln!(io::stderr(), "Failed to open output file '{}': {}", path, err).ok(); - }, - DoitError::ApiError(err) => { - if debug { - writeln!(io::stderr(), "{:#?}", err).ok(); - } else { - writeln!(io::stderr(), "{}", err).ok(); - } - } - } - } - } - } - - std::process::exit(exit_status); -} \ No newline at end of file diff --git a/gen/consumersurveys2/Cargo.toml b/gen/consumersurveys2/Cargo.toml deleted file mode 100644 index 24f07b8ed0..0000000000 --- a/gen/consumersurveys2/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-consumersurveys2" -version = "0.1.14+20160405" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with consumersurveys (protocol v2)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/consumersurveys2" -documentation = "http://byron.github.io/google-apis-rs/google_consumersurveys2" -license = "MIT" -keywords = ["consumersurveys", "google", "protocol", "web", "api"] -build = "src/build.rs" - - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -url = "= 0.5" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - diff --git a/gen/consumersurveys2/LICENSE.md b/gen/consumersurveys2/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/consumersurveys2/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/consumersurveys2/README.md b/gen/consumersurveys2/README.md deleted file mode 100644 index 5c692a7a8f..0000000000 --- a/gen/consumersurveys2/README.md +++ /dev/null @@ -1,184 +0,0 @@ - -The `google-consumersurveys2` library allows access to all features of the *Google consumersurveys* service. - -This documentation was generated from *consumersurveys* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *consumersurveys:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. -# Features - -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.Consumersurveys.html) ... - -* results - * [*get*](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.ResultGetCall.html) -* [surveys](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.Survey.html) - * [*get*](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.SurveyGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.SurveyInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.SurveyListCall.html), [*start*](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.SurveyStartCall.html), [*stop*](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.SurveyStopCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.SurveyUpdateCall.html) - - -Download supported by ... - -* [*get results*](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.ResultGetCall.html) - - - -# Structure of this Library - -The API is structured into the following primary items: - -* **[Hub](http://byron.github.io/google-apis-rs/google_consumersurveys2/struct.Consumersurveys.html)** - * a central object to maintain state and allow accessing all *Activities* - * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.MethodsBuilder.html) which in turn - allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.CallBuilder.html) -* **[Resources](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.Resource.html)** - * primary types that you can apply *Activities* to - * a collection of properties and *Parts* - * **[Parts](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.Part.html)** - * a collection of properties - * never directly used in *Activities* -* **[Activities](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.CallBuilder.html)** - * 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() -``` - -Or specifically ... - -```ignore -let r = hub.surveys().insert(...).doit() -let r = hub.surveys().list(...).doit() -let r = hub.surveys().update(...).doit() -let r = hub.surveys().get(...).doit() -let r = hub.surveys().stop(...).doit() -let r = hub.surveys().start(...).doit() -``` - -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-consumersurveys2 = "*" -``` - -## A complete example - -```Rust -extern crate hyper; -extern crate yup_oauth2 as oauth2; -extern crate google_consumersurveys2 as consumersurveys2; -use consumersurveys2::{Result, Error}; -use std::default::Default; -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use consumersurveys2::Consumersurveys; - -// Get an ApplicationSecret instance by some means. It contains the `client_id` and -// `client_secret`, among other things. -let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - ::default(), None); -let mut hub = Consumersurveys::new(hyper::Client::new(), auth); -// 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.surveys().list() - .token("eirmod") - .start_index(53) - .max_results(36) - .doit(); - -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::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](http://byron.github.io/google-apis-rs/google_consumersurveys2/enum.Result.html) enumeration as return value of -the doit() methods, or handed as possibly intermediate results to either the -[Hub Delegate](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_consumersurveys2/../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](http://byron.github.io/google-apis-rs/google_consumersurveys2/enum.Result.html), should be -read by you to obtain the media. -If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.ResponseResult.html), 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](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.Delegate.html) to the -[Method Builder](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.CallBuilder.html) 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](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.Delegate.html) 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 [enocodable](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.RequestValue.html) and -[decodable](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -are valid. -Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.Part.html) 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](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.CallBuilder.html), 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](http://byron.github.io/google-apis-rs/google_consumersurveys2/trait.RequestValue.html) 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 **consumersurveys2** 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-rs/LICENSE.md diff --git a/gen/consumersurveys2/src/build.rs b/gen/consumersurveys2/src/build.rs deleted file mode 100644 index 0bebaf0bf0..0000000000 --- a/gen/consumersurveys2/src/build.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[cfg(feature = "with-serde-codegen")] -mod inner { - extern crate serde_codegen; - - use std::env; - use std::path::Path; - - pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - - let src = Path::new("src/lib.rs.in"); - let dst = Path::new(&out_dir).join("lib.rs"); - - serde_codegen::expand(&src, &dst).unwrap(); - } -} - -#[cfg(not(feature = "with-serde-codegen"))] -mod inner { - pub fn main() {} -} - -pub fn main() { - inner::main() -} \ No newline at end of file diff --git a/gen/consumersurveys2/src/cmn.rs b/gen/consumersurveys2/src/cmn.rs deleted file mode 100644 index d75063e466..0000000000 --- a/gen/consumersurveys2/src/cmn.rs +++ /dev/null @@ -1,753 +0,0 @@ -// COPY OF 'src/rust/api/cmn.rs' -// DO NOT EDIT -use std::io::{self, Read, Seek, Cursor, Write, SeekFrom}; -use std; -use std::fmt::{self, Display}; -use std::str::FromStr; -use std::error; -use std::thread::sleep; -use std::time::Duration; - -use mime::{Mime, TopLevel, SubLevel, Attr, Value}; -use oauth2::{TokenType, Retry, self}; -use hyper; -use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header, - HeaderFormat, Bearer}; -use hyper::http::h1::LINE_ENDING; -use hyper::method::Method; -use hyper::status::StatusCode; - -use serde_json as json; - -/// 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 {} -impl 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 utility type which can decode a server response that indicates error -#[derive(Deserialize)] -pub struct JsonServerError { - pub error: String, - pub error_description: Option -} - -/// A utility to represent detailed errors we might see in case there are BadRequests. -/// The latter happen if the sent parameters or request structures are unsound -#[derive(Deserialize, Serialize, Debug)] -pub struct ErrorResponse { - error: ServerError, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerError { - errors: Vec, - code: u16, - message: String, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerMessage { - domain: String, - reason: String, - message: String, - #[serde(rename="locationType")] - location_type: Option, - location: Option -} - -#[derive(Copy, Clone)] -pub struct DummyNetworkStream; - -impl Read for DummyNetworkStream { - fn read(&mut self, _: &mut [u8]) -> io::Result { - Ok(0) - } -} - -impl Write for DummyNetworkStream { - fn write(&mut self, _: &[u8]) -> io::Result { - Ok(0) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl hyper::net::NetworkStream for DummyNetworkStream { - fn peer_addr(&mut self) -> io::Result { - Ok("127.0.0.1:1337".parse().unwrap()) - } - - fn set_read_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } - - fn set_write_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } -} - - -/// 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 { - - /// 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, MethodInfo) {} - - /// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), 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, &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 { - 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: &error::Error) -> Option { - 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 { - 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::client::Response, Option, _: Option) -> 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(ErrorResponse), - - /// 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(Box), - - /// 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::client::Response), -} - - -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - 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 err) => { - try!(writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message)); - for err in err.error.errors.iter() { - try!(writeln!(f, " {}: {}, {}{}", - err.domain, - err.message, - err.reason, - match &err.location { - &Some(ref loc) => format!("@{}", loc), - &None => String::new(), - })); - } - 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 description(&self) -> &str { - match *self { - Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(_, ref err) => err.description(), - _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" - } - } - - fn cause(&self) -> Option<&error::Error> { - match *self { - Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(_, ref err) => err.cause(), - _ => None - } - } -} - -/// A universal result type used as return for all calls. -pub type Result = std::result::Result; - -/// Contains information about an API request. -pub struct MethodInfo { - pub id: &'static str, - pub http_method: Method, -} - -const BOUNDARY: &'static 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<(Headers, &'a mut Read)>, - current_part: Option<(Cursor>, &'a mut Read)>, - last_part_boundary: Option>>, -} - -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 Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> { - let mut headers = Headers::new(); - headers.set(ContentType(mime_type)); - headers.set(ContentLength(size)); - 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.len() == 0 && 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.len() == 0 && self.current_part.is_some() - } -} - -impl<'a> Read for MultiPartReader<'a> { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - 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::::new()); - (write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING, - headers, 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).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<'a>(&'a self) -> &'a Mime { &self.0 } -} -impl ::std::ops::DerefMut for XUploadContentType { - fn deref_mut<'a>(&'a mut self) -> &'a mut Mime { &mut self.0 } -} -impl Header for XUploadContentType { - fn header_name() -> &'static str { "X-Upload-Content-Type" } - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - hyper::header::parsing::from_one_raw_str(raw).map(XUploadContentType) - } -} -impl HeaderFormat for XUploadContentType { - fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&**self, f) - } -} -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 { - 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, - pub total_length: u64, -} - -impl Header for ContentRange { - fn header_name() -> &'static str { - "Content-Range" - } - - /// We are not parsable, as parsing is done by the `Range` header - fn parse_header(_: &[Vec]) -> hyper::error::Result { - Err(hyper::error::Error::Method) - } -} - - -impl HeaderFormat for ContentRange { - fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes ")); - match self.range { - Some(ref c) => try!(c.fmt(fmt)), - None => try!(fmt.write_str("*")) - } - (write!(fmt, "/{}", self.total_length)).ok(); - Ok(()) - } -} - -#[derive(Clone, PartialEq, Debug)] -pub struct RangeResponseHeader(pub Chunk); - -impl Header for RangeResponseHeader { - fn header_name() -> &'static str { - "Range" - } - - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - if raw.len() > 0 { - let v = &raw[0]; - if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes "; - if s.starts_with(PREFIX) { - if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { - return Ok(RangeResponseHeader(c)) - } - } - } - } - Err(hyper::error::Error::Method) - } -} - -impl HeaderFormat for RangeResponseHeader { - /// No implmentation necessary, we just need to parse - fn fmt_header(&self, _: &mut fmt::Formatter) -> fmt::Result { - Err(fmt::Error) - } -} - -/// A utility type to perform a resumable upload from start to end. -pub struct ResumableUploadHelper<'a, A: 'a> { - pub client: &'a mut hyper::client::Client, - pub delegate: &'a mut Delegate, - pub start_at: Option, - pub auth: &'a mut A, - pub user_agent: &'a str, - pub auth_header: Authorization, - pub url: &'a str, - pub reader: &'a mut ReadSeek, - pub media_type: Mime, - pub content_length: u64 -} - -impl<'a, A> ResumableUploadHelper<'a, A> - where A: oauth2::GetToken { - - fn query_transfer_status(&mut self) -> std::result::Result> { - loop { - match self.client.post(self.url) - .header(UserAgent(self.user_agent.to_string())) - .header(ContentRange { range: None, total_length: self.content_length }) - .header(self.auth_header.clone()) - .send() { - Ok(r) => { - // 308 = resume-incomplete == PermanentRedirect - let headers = r.headers.clone(); - let h: &RangeResponseHeader = match headers.get() { - Some(hh) if r.status == StatusCode::PermanentRedirect => hh, - None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None, 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 fn upload(&mut self) -> Option> { - let mut start = match self.start_at { - Some(s) => s, - None => match self.query_transfer_status() { - 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 - }; - - self.reader.seek(SeekFrom::Start(start)).unwrap(); - loop { - 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 range_header = ContentRange { - range: Some(Chunk {first: start, last: start + request_size - 1}), - total_length: self.content_length - }; - start += request_size; - if self.delegate.cancel_chunk_upload(&range_header) { - return None - } - let res = self.client.post(self.url) - .header(range_header) - .header(ContentType(self.media_type.clone())) - .header(UserAgent(self.user_agent.to_string())) - .body(&mut section_reader) - .send(); - match res { - Ok(mut res) => { - if res.status == StatusCode::PermanentRedirect { - continue - } - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - } - return Some(Ok(res)) - }, - Err(err) => { - if let Retry::After(d) = self.delegate.http_error(&err) { - sleep(d); - continue; - } - return Some(Err(err)) - } - } - } - } -} - -// Copy of src/rust/cli/cmn.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); - } - } - _ => {} - } -} diff --git a/gen/consumersurveys2/src/lib.rs b/gen/consumersurveys2/src/lib.rs deleted file mode 100644 index 7da6c8ab78..0000000000 --- a/gen/consumersurveys2/src/lib.rs +++ /dev/null @@ -1,194 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.mako' -// DO NOT EDIT ! - -//! This documentation was generated from *consumersurveys* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *consumersurveys:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. -//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/consumersurveys2). -//! # Features -//! -//! Handle the following *Resources* with ease from the central [hub](struct.Consumersurveys.html) ... -//! -//! * results -//! * [*get*](struct.ResultGetCall.html) -//! * [surveys](struct.Survey.html) -//! * [*get*](struct.SurveyGetCall.html), [*insert*](struct.SurveyInsertCall.html), [*list*](struct.SurveyListCall.html), [*start*](struct.SurveyStartCall.html), [*stop*](struct.SurveyStopCall.html) and [*update*](struct.SurveyUpdateCall.html) -//! -//! -//! Download supported by ... -//! -//! * [*get results*](struct.ResultGetCall.html) -//! -//! -//! -//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html). -//! -//! # Structure of this Library -//! -//! The API is structured into the following primary items: -//! -//! * **[Hub](struct.Consumersurveys.html)** -//! * a central object to maintain state and allow accessing all *Activities* -//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn -//! allow access to individual [*Call Builders*](trait.CallBuilder.html) -//! * **[Resources](trait.Resource.html)** -//! * primary types that you can apply *Activities* to -//! * a collection of properties and *Parts* -//! * **[Parts](trait.Part.html)** -//! * a collection of properties -//! * never directly used in *Activities* -//! * **[Activities](trait.CallBuilder.html)** -//! * 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() -//! ``` -//! -//! Or specifically ... -//! -//! ```ignore -//! let r = hub.surveys().insert(...).doit() -//! let r = hub.surveys().list(...).doit() -//! let r = hub.surveys().update(...).doit() -//! let r = hub.surveys().get(...).doit() -//! let r = hub.surveys().stop(...).doit() -//! let r = hub.surveys().start(...).doit() -//! ``` -//! -//! 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-consumersurveys2 = "*" -//! ``` -//! -//! ## A complete example -//! -//! ```test_harness,no_run -//! extern crate hyper; -//! extern crate yup_oauth2 as oauth2; -//! extern crate google_consumersurveys2 as consumersurveys2; -//! use consumersurveys2::{Result, Error}; -//! # #[test] fn egal() { -//! use std::default::Default; -//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use consumersurveys2::Consumersurveys; -//! -//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and -//! // `client_secret`, among other things. -//! let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -//! hyper::Client::new(), -//! ::default(), None); -//! let mut hub = Consumersurveys::new(hyper::Client::new(), auth); -//! // 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.surveys().list() -//! .token("nonumy") -//! .start_index(82) -//! .max_results(40) -//! .doit(); -//! -//! 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::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](enum.Result.html) enumeration as return value of -//! the doit() methods, or handed as possibly intermediate results to either the -//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../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](enum.Result.html), should be -//! read by you to obtain the media. -//! If such a method also supports a [Response Result](trait.ResponseResult.html), 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](trait.Delegate.html) to the -//! [Method Builder](trait.CallBuilder.html) 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](trait.Delegate.html) 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 [enocodable](trait.RequestValue.html) and -//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -//! are valid. -//! Most optionals are are considered [Parts](trait.Part.html) 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](trait.CallBuilder.html), 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](trait.RequestValue.html) 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 ... . -#![cfg_attr(feature = "nightly", feature(custom_derive, custom_attribute, plugin))] -#![cfg_attr(feature = "nightly", plugin(serde_macros))] -#![allow(unused_imports, unused_mut, dead_code)] - -#[cfg(feature = "nightly")] -include!("lib.rs.in"); - -#[cfg(feature = "with-serde-codegen")] -include!(concat!(env!("OUT_DIR"), "/lib.rs")); \ No newline at end of file diff --git a/gen/consumersurveys2/src/lib.rs.in b/gen/consumersurveys2/src/lib.rs.in deleted file mode 100644 index b005aa6c0e..0000000000 --- a/gen/consumersurveys2/src/lib.rs.in +++ /dev/null @@ -1,2447 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.in.mako' -// DO NOT EDIT ! - -extern crate hyper; -extern crate serde; -extern crate serde_json; -extern crate yup_oauth2 as oauth2; -extern crate mime; -extern crate url; - -mod cmn; - -use std::collections::HashMap; -use std::cell::RefCell; -use std::borrow::BorrowMut; -use std::default::Default; -use std::collections::BTreeMap; -use serde_json as json; -use std::io; -use std::fs; -use std::thread::sleep; -use std::time::Duration; - -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, - ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, - Resource, ErrorResponse, remove_json_null_values}; - - -// ############## -// UTILITIES ### -// ############ - -/// Identifies the an OAuth2 authorization scope. -/// A scope is needed when requesting an -/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). -#[derive(PartialEq, Eq, Hash)] -pub enum Scope { - /// View your email address - UserinfoEmail, - - /// View the results for your surveys - Readonly, - - /// View and edit your surveys and results - Full, -} - -impl AsRef for Scope { - fn as_ref(&self) -> &str { - match *self { - Scope::UserinfoEmail => "https://www.googleapis.com/auth/userinfo.email", - Scope::Readonly => "https://www.googleapis.com/auth/consumersurveys.readonly", - Scope::Full => "https://www.googleapis.com/auth/consumersurveys", - } - } -} - -impl Default for Scope { - fn default() -> Scope { - Scope::Readonly - } -} - - - -// ######## -// HUB ### -// ###### - -/// Central instance to access all Consumersurveys related resource activities -/// -/// # Examples -/// -/// Instantiate a new hub -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_consumersurveys2 as consumersurveys2; -/// use consumersurveys2::{Result, Error}; -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use consumersurveys2::Consumersurveys; -/// -/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and -/// // `client_secret`, among other things. -/// let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Consumersurveys::new(hyper::Client::new(), auth); -/// // 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.surveys().list() -/// .token("sed") -/// .start_index(16) -/// .max_results(83) -/// .doit(); -/// -/// 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::MissingAPIKey -/// |Error::MissingToken(_) -/// |Error::Cancelled -/// |Error::UploadSizeLimitExceeded(_, _) -/// |Error::Failure(_) -/// |Error::BadRequest(_) -/// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_, _) => println!("{}", e), -/// }, -/// Ok(res) => println!("Success: {:?}", res), -/// } -/// # } -/// ``` -pub struct Consumersurveys { - client: RefCell, - auth: RefCell, - _user_agent: String, -} - -impl<'a, C, A> Hub for Consumersurveys {} - -impl<'a, C, A> Consumersurveys - where C: BorrowMut, A: oauth2::GetToken { - - pub fn new(client: C, authenticator: A) -> Consumersurveys { - Consumersurveys { - client: RefCell::new(client), - auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.14".to_string(), - } - } - - pub fn results(&'a self) -> ResultMethods<'a, C, A> { - ResultMethods { hub: &self } - } - pub fn surveys(&'a self) -> SurveyMethods<'a, C, A> { - SurveyMethods { hub: &self } - } - - /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.14`. - /// - /// Returns the previously set user-agent. - pub fn user_agent(&mut self, agent_name: String) -> String { - let prev = self._user_agent.clone(); - self._user_agent = agent_name; - prev - } -} - - -// ############ -// SCHEMAS ### -// ########## -/// Reference to the current results for a given survey. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get results](struct.ResultGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SurveyResults { - /// Human readable string describing the status of the request. - pub status: Option, - /// External survey ID as viewable by survey owners in the editor view. - #[serde(rename="surveyUrlId")] - pub survey_url_id: Option, -} - -impl ResponseResult for SurveyResults {} - - -/// Specifications for the target audience of a survey run through the API. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SurveyAudience { - /// Language code that surveys should be targeted to. For instance, 'en-US'. Surveys may target bilingual users by specifying a list of language codes (for example, 'de' and 'en-US'). In that case, all languages will be used for targeting users but the survey content (which is displayed) must match the first language listed. Accepts standard BCP47 language codes. See specification. - pub languages: Option>, - /// Country subdivision (states/provinces/etc) that surveys should be targeted to. For all countries except GB, ISO-3166-2 subdivision code is required (eg. 'US-OH' for Ohio, United States). For GB, NUTS 1 statistical region codes for the United Kingdom is required (eg. 'UK-UKC' for North East England). - #[serde(rename="countrySubdivision")] - pub country_subdivision: Option, - /// Required country code that surveys should be targeted to. Accepts standard ISO 3166-1 2 character language codes. For instance, 'US' for the United States, and 'GB' for the United Kingdom. - pub country: Option, - /// Optional gender to target. - pub gender: Option, - /// Optional list of age buckets to target. Supported age buckets are: ['18-24', '25-34', '35-44', '45-54', '55-64', '65+'] - pub ages: Option>, - /// Online population source where the respondents are sampled from. - #[serde(rename="populationSource")] - pub population_source: Option, -} - -impl Part for SurveyAudience {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TokenPagination { - /// no description provided - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// no description provided - #[serde(rename="previousPageToken")] - pub previous_page_token: Option, -} - -impl Part for TokenPagination {} - - -/// Container object for image data and alt_text. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SurveyQuestionImage { - /// The read-only URL for the hosted images. - pub url: Option, - /// The alt text property used in image tags is required for all images. - #[serde(rename="altText")] - pub alt_text: Option, - /// Inline jpeg, gif, tiff, bmp, or png image raw bytes for an image question types. - pub data: Option, -} - -impl Part for SurveyQuestionImage {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get results](struct.ResultGetCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ResultsGetRequest { - /// no description provided - #[serde(rename="resultMask")] - pub result_mask: Option, -} - -impl RequestValue for ResultsGetRequest {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct FieldMask { - /// no description provided - pub fields: Option>, - /// no description provided - pub id: Option, -} - -impl Part for FieldMask {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [start surveys](struct.SurveyStartCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SurveysStartResponse { - /// Survey object containing the specification of the started Survey. - pub resource: Option, - /// Unique request ID used for logging and debugging. Please include in any error reporting or troubleshooting requests. - #[serde(rename="requestId")] - pub request_id: Option, -} - -impl ResponseResult for SurveysStartResponse {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list surveys](struct.SurveyListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SurveysListResponse { - /// no description provided - #[serde(rename="tokenPagination")] - pub token_pagination: Option, - /// no description provided - #[serde(rename="pageInfo")] - pub page_info: Option, - /// An individual survey resource. - pub resources: Option>, - /// Unique request ID used for logging and debugging. Please include in any error reporting or troubleshooting requests. - #[serde(rename="requestId")] - pub request_id: Option, -} - -impl ResponseResult for SurveysListResponse {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ResultsMask { - /// no description provided - pub fields: Option>, - /// no description provided - pub projection: Option, -} - -impl Part for ResultsMask {} - - -/// Representation of an individual survey object. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [insert surveys](struct.SurveyInsertCall.html) (request|response) -/// * [list surveys](struct.SurveyListCall.html) (none) -/// * [update surveys](struct.SurveyUpdateCall.html) (request|response) -/// * [get surveys](struct.SurveyGetCall.html) (response) -/// * [stop surveys](struct.SurveyStopCall.html) (none) -/// * [start surveys](struct.SurveyStartCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Survey { - /// List of email addresses for survey owners. Must contain at least the address of the user making the API call. - pub owners: Option>, - /// Text description of the survey. - pub description: Option, - /// Optional name that will be given to the survey. - pub title: Option, - /// Additional information to store on behalf of the API consumer and associate with this question. This binary blob is treated as opaque. This field is limited to 64K bytes. - #[serde(rename="customerData")] - pub customer_data: Option, - /// State that the survey is in. Can be modified to start, stop, or pause survey. - pub state: Option, - /// Targeting-criteria message containing demographic information - pub audience: Option, - /// Cost to run the survey and collect the necessary number of responses. - pub cost: Option, - /// Unique survey ID, that is viewable in the URL of the Survey Creator UI - #[serde(rename="surveyUrlId")] - pub survey_url_id: Option, - /// List of questions defining the survey. - pub questions: Option>, - /// Number of responses desired for the survey. - #[serde(rename="wantedResponseCount")] - pub wanted_response_count: Option, -} - -impl RequestValue for Survey {} -impl Resource for Survey {} -impl ResponseResult for Survey {} - - -/// Message defining the cost to run a given survey through API. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SurveyCost { - /// Cost of survey in nano units of the given currency. - pub nanos: Option, - /// Currency code that the cost is given in. - #[serde(rename="currencyCode")] - pub currency_code: Option, -} - -impl Part for SurveyCost {} - - -/// Message defining the question specifications. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SurveyQuestion { - /// Option to force the user to pick one of the open text suggestions. This requires that suggestions are provided for this question. - #[serde(rename="mustPickSuggestion")] - pub must_pick_suggestion: Option, - /// The threshold/screener answer options, which will screen a user into the rest of the survey. These will be a subset of the answer option strings. - #[serde(rename="thresholdAnswers")] - pub threshold_answers: Option>, - /// Number of stars to use for ratings questions. - #[serde(rename="numStars")] - pub num_stars: Option, - /// For rating questions, the text for the lower end of the scale, such as 'Worst'. For numeric questions, a string representing a floating-point that is the minimum allowed number for a response. - #[serde(rename="lowValueLabel")] - pub low_value_label: Option, - /// The YouTube video ID to be show in video questions. - #[serde(rename="videoId")] - pub video_id: Option, - /// Required list of answer options for a question. - pub answers: Option>, - /// Option to allow open-ended text box for Single Answer and Multiple Answer question types. This can be used with SINGLE_ANSWER, SINGLE_ANSWER_WITH_IMAGE, MULTIPLE_ANSWERS, and MULTIPLE_ANSWERS_WITH_IMAGE question types. - #[serde(rename="hasOther")] - pub has_other: Option, - /// no description provided - pub images: Option>, - /// Optional unit of measurement for display (for example: hours, people, miles). - #[serde(rename="unitOfMeasurementLabel")] - pub unit_of_measurement_label: Option, - /// Currently only support pinning an answer option to the last position. - #[serde(rename="lastAnswerPositionPinned")] - pub last_answer_position_pinned: Option, - /// A list of suggested answers for open text question auto-complete. This is only valid if single_line_response is true. - #[serde(rename="openTextSuggestions")] - pub open_text_suggestions: Option>, - /// For rating questions, the text for the higher end of the scale, such as 'Best'. For numeric questions, a string representing a floating-point that is the maximum allowed number for a response. - #[serde(rename="highValueLabel")] - pub high_value_label: Option, - /// Required question text shown to the respondent. - pub question: Option, - /// Used by the Rating Scale with Text question type. This text goes along with the question field that is presented to the respondent, and is the actual text that the respondent is asked to rate. - #[serde(rename="sentimentText")] - pub sentiment_text: Option, - /// Option to allow multiple line open text responses instead of a single line response. Note that we don't show auto-complete suggestions with multiple line responses. - #[serde(rename="singleLineResponse")] - pub single_line_response: Option, - /// Required field defining the question type. For details about configuring different type of questions, consult the question configuration guide. - #[serde(rename="type")] - pub type_: Option, - /// The randomization option for multiple choice and multi-select questions. If not specified, this option defaults to randomize. - #[serde(rename="answerOrder")] - pub answer_order: Option, - /// Placeholder text for an open text question. - #[serde(rename="openTextPlaceholder")] - pub open_text_placeholder: Option, -} - -impl Part for SurveyQuestion {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PageInfo { - /// no description provided - #[serde(rename="resultPerPage")] - pub result_per_page: Option, - /// no description provided - #[serde(rename="startIndex")] - pub start_index: Option, - /// no description provided - #[serde(rename="totalResults")] - pub total_results: Option, -} - -impl Part for PageInfo {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [stop surveys](struct.SurveyStopCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SurveysStopResponse { - /// Survey object containing the specification of the stopped Survey. - pub resource: Option, - /// Unique request ID used for logging and debugging. Please include in any error reporting or troubleshooting requests. - #[serde(rename="requestId")] - pub request_id: Option, -} - -impl ResponseResult for SurveysStopResponse {} - - - -// ################### -// MethodBuilders ### -// ################# - -/// A builder providing access to all methods supported on *survey* resources. -/// It is not used directly, but through the `Consumersurveys` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_consumersurveys2 as consumersurveys2; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use consumersurveys2::Consumersurveys; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Consumersurveys::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)`, `insert(...)`, `list(...)`, `start(...)`, `stop(...)` and `update(...)` -/// // to build up your call. -/// let rb = hub.surveys(); -/// # } -/// ``` -pub struct SurveyMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Consumersurveys, -} - -impl<'a, C, A> MethodsBuilder for SurveyMethods<'a, C, A> {} - -impl<'a, C, A> SurveyMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Creates a survey. - /// - /// # Arguments - /// - /// * `request` - No description provided. - pub fn insert(&self, request: Survey) -> SurveyInsertCall<'a, C, A> { - SurveyInsertCall { - hub: self.hub, - _request: request, - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists the surveys owned by the authenticated user. - pub fn list(&self) -> SurveyListCall<'a, C, A> { - SurveyListCall { - hub: self.hub, - _token: Default::default(), - _start_index: Default::default(), - _max_results: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates a survey. Currently the only property that can be updated is the owners property. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `surveyUrlId` - External URL ID for the survey. - pub fn update(&self, request: Survey, survey_url_id: &str) -> SurveyUpdateCall<'a, C, A> { - SurveyUpdateCall { - hub: self.hub, - _request: request, - _survey_url_id: survey_url_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves information about the specified survey. - /// - /// # Arguments - /// - /// * `surveyUrlId` - External URL ID for the survey. - pub fn get(&self, survey_url_id: &str) -> SurveyGetCall<'a, C, A> { - SurveyGetCall { - hub: self.hub, - _survey_url_id: survey_url_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Stops a running survey. - /// - /// # Arguments - /// - /// * `resourceId` - No description provided. - pub fn stop(&self, resource_id: &str) -> SurveyStopCall<'a, C, A> { - SurveyStopCall { - hub: self.hub, - _resource_id: resource_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Begins running a survey. - /// - /// # Arguments - /// - /// * `resourceId` - No description provided. - pub fn start(&self, resource_id: &str) -> SurveyStartCall<'a, C, A> { - SurveyStartCall { - hub: self.hub, - _resource_id: resource_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *result* resources. -/// It is not used directly, but through the `Consumersurveys` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_consumersurveys2 as consumersurveys2; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use consumersurveys2::Consumersurveys; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Consumersurveys::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)` -/// // to build up your call. -/// let rb = hub.results(); -/// # } -/// ``` -pub struct ResultMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Consumersurveys, -} - -impl<'a, C, A> MethodsBuilder for ResultMethods<'a, C, A> {} - -impl<'a, C, A> ResultMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves any survey results that have been produced so far. Results are formatted as an Excel file. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `surveyUrlId` - External URL ID for the survey. - pub fn get(&self, request: ResultsGetRequest, survey_url_id: &str) -> ResultGetCall<'a, C, A> { - ResultGetCall { - hub: self.hub, - _request: request, - _survey_url_id: survey_url_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - - - -// ################### -// CallBuilders ### -// ################# - -/// Creates a survey. -/// -/// A builder for the *insert* method supported by a *survey* resource. -/// It is not used directly, but through a `SurveyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_consumersurveys2 as consumersurveys2; -/// use consumersurveys2::Survey; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use consumersurveys2::Consumersurveys; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Consumersurveys::new(hyper::Client::new(), 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 = Survey::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.surveys().insert(req) -/// .doit(); -/// # } -/// ``` -pub struct SurveyInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Consumersurveys, - _request: Survey, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SurveyInsertCall<'a, C, A> {} - -impl<'a, C, A> SurveyInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Survey)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "consumersurveys.surveys.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - for &field in ["alt"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/consumersurveys/v2/surveys".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Survey) -> SurveyInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SurveyInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SurveyInsertCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SurveyInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Lists the surveys owned by the authenticated user. -/// -/// A builder for the *list* method supported by a *survey* resource. -/// It is not used directly, but through a `SurveyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_consumersurveys2 as consumersurveys2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use consumersurveys2::Consumersurveys; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Consumersurveys::new(hyper::Client::new(), auth); -/// // 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.surveys().list() -/// .token("kasd") -/// .start_index(79) -/// .max_results(93) -/// .doit(); -/// # } -/// ``` -pub struct SurveyListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Consumersurveys, - _token: Option, - _start_index: Option, - _max_results: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SurveyListCall<'a, C, A> {} - -impl<'a, C, A> SurveyListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SurveysListResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "consumersurveys.surveys.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - if let Some(value) = self._token { - params.push(("token", value.to_string())); - } - if let Some(value) = self._start_index { - params.push(("startIndex", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - for &field in ["alt", "token", "startIndex", "maxResults"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/consumersurveys/v2/surveys".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *token* query property to the given value. - pub fn token(mut self, new_value: &str) -> SurveyListCall<'a, C, A> { - self._token = Some(new_value.to_string()); - self - } - /// - /// Sets the *start index* query property to the given value. - pub fn start_index(mut self, new_value: u32) -> SurveyListCall<'a, C, A> { - self._start_index = Some(new_value); - self - } - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> SurveyListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SurveyListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SurveyListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SurveyListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates a survey. Currently the only property that can be updated is the owners property. -/// -/// A builder for the *update* method supported by a *survey* resource. -/// It is not used directly, but through a `SurveyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_consumersurveys2 as consumersurveys2; -/// use consumersurveys2::Survey; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use consumersurveys2::Consumersurveys; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Consumersurveys::new(hyper::Client::new(), 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 = Survey::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.surveys().update(req, "surveyUrlId") -/// .doit(); -/// # } -/// ``` -pub struct SurveyUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Consumersurveys, - _request: Survey, - _survey_url_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SurveyUpdateCall<'a, C, A> {} - -impl<'a, C, A> SurveyUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Survey)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "consumersurveys.surveys.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("surveyUrlId", self._survey_url_id.to_string())); - for &field in ["alt", "surveyUrlId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/consumersurveys/v2/surveys/{surveyUrlId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{surveyUrlId}", "surveyUrlId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["surveyUrlId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Survey) -> SurveyUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// External URL ID for the survey. - /// - /// Sets the *survey url id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn survey_url_id(mut self, new_value: &str) -> SurveyUpdateCall<'a, C, A> { - self._survey_url_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SurveyUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SurveyUpdateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SurveyUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves information about the specified survey. -/// -/// A builder for the *get* method supported by a *survey* resource. -/// It is not used directly, but through a `SurveyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_consumersurveys2 as consumersurveys2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use consumersurveys2::Consumersurveys; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Consumersurveys::new(hyper::Client::new(), auth); -/// // 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.surveys().get("surveyUrlId") -/// .doit(); -/// # } -/// ``` -pub struct SurveyGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Consumersurveys, - _survey_url_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SurveyGetCall<'a, C, A> {} - -impl<'a, C, A> SurveyGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Survey)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "consumersurveys.surveys.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("surveyUrlId", self._survey_url_id.to_string())); - for &field in ["alt", "surveyUrlId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/consumersurveys/v2/surveys/{surveyUrlId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{surveyUrlId}", "surveyUrlId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["surveyUrlId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// External URL ID for the survey. - /// - /// Sets the *survey url id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn survey_url_id(mut self, new_value: &str) -> SurveyGetCall<'a, C, A> { - self._survey_url_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SurveyGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SurveyGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SurveyGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Stops a running survey. -/// -/// A builder for the *stop* method supported by a *survey* resource. -/// It is not used directly, but through a `SurveyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_consumersurveys2 as consumersurveys2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use consumersurveys2::Consumersurveys; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Consumersurveys::new(hyper::Client::new(), auth); -/// // 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.surveys().stop("resourceId") -/// .doit(); -/// # } -/// ``` -pub struct SurveyStopCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Consumersurveys, - _resource_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SurveyStopCall<'a, C, A> {} - -impl<'a, C, A> SurveyStopCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SurveysStopResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "consumersurveys.surveys.stop", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("resourceId", self._resource_id.to_string())); - for &field in ["alt", "resourceId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/consumersurveys/v2/surveys/{resourceId}/stop".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{resourceId}", "resourceId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["resourceId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *resource id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn resource_id(mut self, new_value: &str) -> SurveyStopCall<'a, C, A> { - self._resource_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SurveyStopCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SurveyStopCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SurveyStopCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Begins running a survey. -/// -/// A builder for the *start* method supported by a *survey* resource. -/// It is not used directly, but through a `SurveyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_consumersurveys2 as consumersurveys2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use consumersurveys2::Consumersurveys; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Consumersurveys::new(hyper::Client::new(), auth); -/// // 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.surveys().start("resourceId") -/// .doit(); -/// # } -/// ``` -pub struct SurveyStartCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Consumersurveys, - _resource_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for SurveyStartCall<'a, C, A> {} - -impl<'a, C, A> SurveyStartCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SurveysStartResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "consumersurveys.surveys.start", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("resourceId", self._resource_id.to_string())); - for &field in ["alt", "resourceId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/consumersurveys/v2/surveys/{resourceId}/start".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{resourceId}", "resourceId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["resourceId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *resource id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn resource_id(mut self, new_value: &str) -> SurveyStartCall<'a, C, A> { - self._resource_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> SurveyStartCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> SurveyStartCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> SurveyStartCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves any survey results that have been produced so far. Results are formatted as an Excel file. -/// -/// This method supports **media download**. To enable it, adjust the builder like this: -/// `.param("alt", "media")`. -/// Please note that due to missing multi-part support on the server side, you will only receive the media, -/// but not the `SurveyResults` structure that you would usually get. The latter will be a default value. -/// -/// A builder for the *get* method supported by a *result* resource. -/// It is not used directly, but through a `ResultMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_consumersurveys2 as consumersurveys2; -/// use consumersurveys2::ResultsGetRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use consumersurveys2::Consumersurveys; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Consumersurveys::new(hyper::Client::new(), 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 = ResultsGetRequest::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.results().get(req, "surveyUrlId") -/// .doit(); -/// # } -/// ``` -pub struct ResultGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Consumersurveys, - _request: ResultsGetRequest, - _survey_url_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ResultGetCall<'a, C, A> {} - -impl<'a, C, A> ResultGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SurveyResults)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "consumersurveys.results.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("surveyUrlId", self._survey_url_id.to_string())); - for &field in ["surveyUrlId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - let (json_field_missing, enable_resource_parsing) = { - let mut enable = true; - let mut field_present = true; - for &(name, ref value) in params.iter() { - if name == "alt" { - field_present = false; - if >::as_ref(&value) != "json" { - enable = false; - } - break; - } - } - (field_present, enable) - }; - if json_field_missing { - params.push(("alt", "json".to_string())); - } - - let mut url = "https://www.googleapis.com/consumersurveys/v2/surveys/{surveyUrlId}/results".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{surveyUrlId}", "surveyUrlId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["surveyUrlId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = if enable_resource_parsing { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - } else { (res, Default::default()) }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: ResultsGetRequest) -> ResultGetCall<'a, C, A> { - self._request = new_value; - self - } - /// External URL ID for the survey. - /// - /// Sets the *survey url id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn survey_url_id(mut self, new_value: &str) -> ResultGetCall<'a, C, A> { - self._survey_url_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ResultGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ResultGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ResultGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - diff --git a/gen/container1-cli/Cargo.toml b/gen/container1-cli/Cargo.toml index 88dfbc0d6d..d9f049d7af 100644 --- a/gen/container1-cli/Cargo.toml +++ b/gen/container1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-container1-cli" -version = "0.3.6+20160421" +version = "1.0.0+20160421" authors = ["Sebastian Thiel "] description = "A complete library to interact with container (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/container1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-container1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-container1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-container1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-container1] path = "../container1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/container1-cli/README.md b/gen/container1-cli/README.md index cea542071e..6f2117b7e5 100644 --- a/gen/container1-cli/README.md +++ b/gen/container1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *container* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/container1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/container1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/container1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/container1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/container1-cli). # Usage -This documentation was generated from the *container* API at revision *20160421*. The CLI is at version *0.3.6*. +This documentation was generated from the *container* API at revision *20160421*. The CLI is at version *1.0.0*. ```bash container1 [options] diff --git a/gen/container1-cli/mkdocs.yml b/gen/container1-cli/mkdocs.yml index bc45a66aa9..c67793dd2a 100644 --- a/gen/container1-cli/mkdocs.yml +++ b/gen/container1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: container v0.3.6+20160421 +site_name: container v1.0.0+20160421 site_url: http://byron.github.io/google-apis-rs/google-container1-cli site_description: Write integrating applications with bcore diff --git a/gen/container1-cli/src/main.rs b/gen/container1-cli/src/main.rs index eaea1ca377..94cdbc91ba 100644 --- a/gen/container1-cli/src/main.rs +++ b/gen/container1-cli/src/main.rs @@ -1371,7 +1371,7 @@ fn main() { let mut app = App::new("container1") .author("Sebastian Thiel ") - .version("0.3.6+20160421") + .version("1.0.0+20160421") .about("Builds and manages clusters that run container-based applications, powered by open source Kubernetes technology.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_container1_cli") .arg(Arg::with_name("url") diff --git a/gen/content2-cli/Cargo.toml b/gen/content2-cli/Cargo.toml index 12e7ed04de..db89af919c 100644 --- a/gen/content2-cli/Cargo.toml +++ b/gen/content2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-content2-cli" -version = "0.3.6+20160905" +version = "1.0.0+20160905" authors = ["Sebastian Thiel "] description = "A complete library to interact with Shopping Content (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/content2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-content2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-content2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-content2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-content2] path = "../content2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/content2-cli/README.md b/gen/content2-cli/README.md index 02b056d0fe..7c2e1a892a 100644 --- a/gen/content2-cli/README.md +++ b/gen/content2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Shopping Content* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/content2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/content2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/content2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/content2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/content2-cli). # Usage -This documentation was generated from the *Shopping Content* API at revision *20160905*. The CLI is at version *0.3.6*. +This documentation was generated from the *Shopping Content* API at revision *20160905*. The CLI is at version *1.0.0*. ```bash content2 [options] diff --git a/gen/content2-cli/mkdocs.yml b/gen/content2-cli/mkdocs.yml index dc4bb8d4b6..498d30a92c 100644 --- a/gen/content2-cli/mkdocs.yml +++ b/gen/content2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Shopping Content v0.3.6+20160905 +site_name: Shopping Content v1.0.0+20160905 site_url: http://byron.github.io/google-apis-rs/google-content2-cli site_description: Write integrating applications with bcore diff --git a/gen/content2-cli/src/main.rs b/gen/content2-cli/src/main.rs index b3540751c2..565749032e 100644 --- a/gen/content2-cli/src/main.rs +++ b/gen/content2-cli/src/main.rs @@ -6842,7 +6842,7 @@ fn main() { let mut app = App::new("content2") .author("Sebastian Thiel ") - .version("0.3.6+20160905") + .version("1.0.0+20160905") .about("Manages product items, inventory, and Merchant Center accounts for Google Shopping.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_content2_cli") .arg(Arg::with_name("url") diff --git a/gen/content2_sandbox-cli/Cargo.toml b/gen/content2_sandbox-cli/Cargo.toml index fc285c2b2f..80c244bcb6 100644 --- a/gen/content2_sandbox-cli/Cargo.toml +++ b/gen/content2_sandbox-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-content2_sandbox-cli" -version = "0.3.6+20160905" +version = "1.0.0+20160905" authors = ["Sebastian Thiel "] description = "A complete library to interact with Shopping Content (protocol v2sandbox)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/content2_sandbox-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-content2_sandbox/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-content2_sandbox/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-content2_sandbox/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-content2_sandbox] path = "../content2_sandbox" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/content2_sandbox-cli/README.md b/gen/content2_sandbox-cli/README.md index 7047fde2c5..9a382ea875 100644 --- a/gen/content2_sandbox-cli/README.md +++ b/gen/content2_sandbox-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Shopping Content* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/content2-sandbox.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/content2-sandbox.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/content2-sandbox.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/content2-sandbox.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/content2_sandbox-cli). # Usage -This documentation was generated from the *Shopping Content* API at revision *20160905*. The CLI is at version *0.3.6*. +This documentation was generated from the *Shopping Content* API at revision *20160905*. The CLI is at version *1.0.0*. ```bash content2-sandbox [options] diff --git a/gen/content2_sandbox-cli/mkdocs.yml b/gen/content2_sandbox-cli/mkdocs.yml index 281d2b205a..51db8e9f65 100644 --- a/gen/content2_sandbox-cli/mkdocs.yml +++ b/gen/content2_sandbox-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Shopping Content v0.3.6+20160905 +site_name: Shopping Content v1.0.0+20160905 site_url: http://byron.github.io/google-apis-rs/google-content2_sandbox-cli site_description: Write integrating applications with bcore diff --git a/gen/content2_sandbox-cli/src/main.rs b/gen/content2_sandbox-cli/src/main.rs index 9dd6429d5c..38f1536531 100644 --- a/gen/content2_sandbox-cli/src/main.rs +++ b/gen/content2_sandbox-cli/src/main.rs @@ -1818,7 +1818,7 @@ fn main() { let mut app = App::new("content2-sandbox") .author("Sebastian Thiel ") - .version("0.3.6+20160905") + .version("1.0.0+20160905") .about("Manages product items, inventory, and Merchant Center accounts for Google Shopping.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_content2_sandbox_cli") .arg(Arg::with_name("url") diff --git a/gen/coordinate1-cli/Cargo.toml b/gen/coordinate1-cli/Cargo.toml index 4b932f3f28..cbb439dfda 100644 --- a/gen/coordinate1-cli/Cargo.toml +++ b/gen/coordinate1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-coordinate1-cli" -version = "0.3.6+20150811" +version = "1.0.0+20150811" authors = ["Sebastian Thiel "] description = "A complete library to interact with coordinate (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/coordinate1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-coordinate1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-coordinate1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-coordinate1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-coordinate1] path = "../coordinate1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/coordinate1-cli/README.md b/gen/coordinate1-cli/README.md index c247084148..8f865a47ff 100644 --- a/gen/coordinate1-cli/README.md +++ b/gen/coordinate1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *coordinate* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/coordinate1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/coordinate1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/coordinate1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/coordinate1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/coordinate1-cli). # Usage -This documentation was generated from the *coordinate* API at revision *20150811*. The CLI is at version *0.3.6*. +This documentation was generated from the *coordinate* API at revision *20150811*. The CLI is at version *1.0.0*. ```bash coordinate1 [options] diff --git a/gen/coordinate1-cli/mkdocs.yml b/gen/coordinate1-cli/mkdocs.yml index a2567e3c57..15f2f5e426 100644 --- a/gen/coordinate1-cli/mkdocs.yml +++ b/gen/coordinate1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: coordinate v0.3.6+20150811 +site_name: coordinate v1.0.0+20150811 site_url: http://byron.github.io/google-apis-rs/google-coordinate1-cli site_description: Write integrating applications with bcore diff --git a/gen/coordinate1-cli/src/main.rs b/gen/coordinate1-cli/src/main.rs index 15d14f02e3..d88ce62738 100644 --- a/gen/coordinate1-cli/src/main.rs +++ b/gen/coordinate1-cli/src/main.rs @@ -1570,7 +1570,7 @@ fn main() { let mut app = App::new("coordinate1") .author("Sebastian Thiel ") - .version("0.3.6+20150811") + .version("1.0.0+20150811") .about("Lets you view and manage jobs in a Coordinate team.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_coordinate1_cli") .arg(Arg::with_name("url") diff --git a/gen/customsearch1-cli/Cargo.toml b/gen/customsearch1-cli/Cargo.toml index 873dcf8d43..124ba163c8 100644 --- a/gen/customsearch1-cli/Cargo.toml +++ b/gen/customsearch1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-customsearch1-cli" -version = "0.3.6+20160411" +version = "1.0.0+20160411" authors = ["Sebastian Thiel "] description = "A complete library to interact with customsearch (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/customsearch1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-customsearch1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-customsearch1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-customsearch1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-customsearch1] path = "../customsearch1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/customsearch1-cli/README.md b/gen/customsearch1-cli/README.md index 9728515cc6..bfdfdb8bd0 100644 --- a/gen/customsearch1-cli/README.md +++ b/gen/customsearch1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *customsearch* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/customsearch1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/customsearch1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/customsearch1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/customsearch1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/customsearch1-cli). # Usage -This documentation was generated from the *customsearch* API at revision *20160411*. The CLI is at version *0.3.6*. +This documentation was generated from the *customsearch* API at revision *20160411*. The CLI is at version *1.0.0*. ```bash customsearch1 [options] diff --git a/gen/customsearch1-cli/mkdocs.yml b/gen/customsearch1-cli/mkdocs.yml index be3825e727..c0db91ad46 100644 --- a/gen/customsearch1-cli/mkdocs.yml +++ b/gen/customsearch1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: customsearch v0.3.6+20160411 +site_name: customsearch v1.0.0+20160411 site_url: http://byron.github.io/google-apis-rs/google-customsearch1-cli site_description: Write integrating applications with bcore diff --git a/gen/customsearch1-cli/src/main.rs b/gen/customsearch1-cli/src/main.rs index 005ad8be94..a26faa8e16 100644 --- a/gen/customsearch1-cli/src/main.rs +++ b/gen/customsearch1-cli/src/main.rs @@ -315,7 +315,7 @@ fn main() { let mut app = App::new("customsearch1") .author("Sebastian Thiel ") - .version("0.3.6+20160411") + .version("1.0.0+20160411") .about("Lets you search over a website or collection of websites") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_customsearch1_cli") .arg(Arg::with_name("folder") diff --git a/gen/dataproc1-cli/Cargo.toml b/gen/dataproc1-cli/Cargo.toml index d5030d7c82..c6d2ff1b6a 100644 --- a/gen/dataproc1-cli/Cargo.toml +++ b/gen/dataproc1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dataproc1-cli" -version = "0.3.6+20160503" +version = "1.0.0+20160503" authors = ["Sebastian Thiel "] description = "A complete library to interact with dataproc (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dataproc1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-dataproc1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-dataproc1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dataproc1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dataproc1] path = "../dataproc1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/dataproc1-cli/README.md b/gen/dataproc1-cli/README.md index c71c301a05..7ae890a523 100644 --- a/gen/dataproc1-cli/README.md +++ b/gen/dataproc1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *dataproc* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/dataproc1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/dataproc1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/dataproc1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/dataproc1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dataproc1-cli). # Usage -This documentation was generated from the *dataproc* API at revision *20160503*. The CLI is at version *0.3.6*. +This documentation was generated from the *dataproc* API at revision *20160503*. The CLI is at version *1.0.0*. ```bash dataproc1 [options] diff --git a/gen/dataproc1-cli/mkdocs.yml b/gen/dataproc1-cli/mkdocs.yml index 453dfa2ba2..be4bfbf927 100644 --- a/gen/dataproc1-cli/mkdocs.yml +++ b/gen/dataproc1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dataproc v0.3.6+20160503 +site_name: dataproc v1.0.0+20160503 site_url: http://byron.github.io/google-apis-rs/google-dataproc1-cli site_description: Write integrating applications with bcore diff --git a/gen/dataproc1-cli/src/main.rs b/gen/dataproc1-cli/src/main.rs index b1233e22c0..53ff89854b 100644 --- a/gen/dataproc1-cli/src/main.rs +++ b/gen/dataproc1-cli/src/main.rs @@ -1774,7 +1774,7 @@ fn main() { let mut app = App::new("dataproc1") .author("Sebastian Thiel ") - .version("0.3.6+20160503") + .version("1.0.0+20160503") .about("Manages Hadoop-based clusters and jobs on Google Cloud Platform.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_dataproc1_cli") .arg(Arg::with_name("url") diff --git a/gen/datastore1_beta2-cli/Cargo.toml b/gen/datastore1_beta2-cli/Cargo.toml deleted file mode 100644 index 573d39cfcf..0000000000 --- a/gen/datastore1_beta2-cli/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-datastore1_beta2-cli" -version = "0.3.5+20160314" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with datastore (protocol v1beta2)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/datastore1_beta2-cli" -homepage = "https://developers.google.com/datastore/" -documentation = "http://byron.github.io/google-apis-rs/google_datastore1_beta2_cli" -license = "MIT" -keywords = ["datastore", "google", "cli"] - -[[bin]] -name = "datastore1-beta2" - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -strsim = "^0.4" -yup-hyper-mock = "^1.0" -clap = "^2.0" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-datastore1_beta2/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-datastore1_beta2/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - - -[dependencies.google-datastore1_beta2] -path = "../datastore1_beta2" -optional = true -default-features = false diff --git a/gen/datastore1_beta2-cli/LICENSE.md b/gen/datastore1_beta2-cli/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/datastore1_beta2-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/datastore1_beta2-cli/README.md b/gen/datastore1_beta2-cli/README.md deleted file mode 100644 index 0500f0a102..0000000000 --- a/gen/datastore1_beta2-cli/README.md +++ /dev/null @@ -1,118 +0,0 @@ - -The `datastore1-beta2` command-line interface *(CLI)* allows to use most features of the *Google datastore* service from the comfort of your terminal. - -By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's -capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. - -If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. - -Everything else about the *datastore* API can be found at the -[official documentation site](https://developers.google.com/datastore/). - -# Downloads - -You can download the pre-compiled 64bit binaries for the following platforms: - -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.5/ubuntu/datastore1-beta2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.5/osx/datastore1-beta2.tar.gz) - -Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/datastore1_beta2-cli). - -# Usage - -This documentation was generated from the *datastore* API at revision *20160314*. The CLI is at version *0.3.5*. - -```bash -datastore1-beta2 [options] - datasets - allocate-ids (-r )... [-p ]... [-o ] - begin-transaction (-r )... [-p ]... [-o ] - commit (-r )... [-p ]... [-o ] - lookup (-r )... [-p ]... [-o ] - rollback (-r )... [-p ]... [-o ] - run-query (-r )... [-p ]... [-o ] - datastore1-beta2 --help - -Configuration: - [--scope ]... - Specify the authentication a method should be executed in. Each scope - requires the user to grant this application permission to use it. - If unset, it defaults to the shortest scope url for a particular method. - --config-dir - A directory into which we will store our persistent data. Defaults to - a user-writable directory that we will create during the first invocation. - [default: ~/.google-service-cli] - --debug - Output all server communication to standard error. `tx` and `rx` are placed - into the same stream. - --debug-auth - Output all communication related to authentication to standard error. `tx` - and `rx` are placed into the same stream. - -``` - -# Configuration - -The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `datastore1-beta2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. - -More information about the various kinds of persistent data are given in the following paragraphs. - -# Authentication - -Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the -set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. - -If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a -method that is read-only, it will ask only for a read-only scope. -You may use the `--scope` flag to specify a scope directly. -All applicable scopes are documented in the respective method's CLI documentation. - -The first time a scope is used, the user is asked for permission. Follow the instructions given -by the CLI to grant permissions, or to decline. - -If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration -directory, e.g. `~/.google-service-cli/datastore1-beta2-token-.json`. No manual management of these tokens -is necessary. - -To revoke granted authentication, please refer to the [official documentation][revoke-access]. - -# Application Secrets - -In order to allow any application to use Google services, it will need to be registered using the -[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it -one by one. Most APIs can be used for free and have a daily quota. - -To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI -comes with a default application secret that is configured accordingly. This also means that heavy usage -all around the world may deplete the daily quota. - -You can workaround this limitation by putting your own secrets file at this location: -`~/.google-service-cli/datastore1-beta2-secret.json`, assuming that the required *datastore* API -was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at -*APIs & auth -> Credentials -> Download JSON* and used as is. - -Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. - - -# Debugging - -Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know -what exactly led to a particular issue. This is done by allowing all client-server communication to be -output to standard error *as-is*. - -The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag -will cause all communication related to authentication to standard error. -If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the -issue at hand. - -You may consider redirecting standard error into a file for ease of use, e.g. `datastore1-beta2 --debug [options] 2>debug.txt`. - - -[scopes]: https://developers.google.com/+/api/oauth#scopes -[revoke-access]: http://webapps.stackexchange.com/a/30849 -[google-dev-console]: https://console.developers.google.com/ -[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/datastore1_beta2-cli/mkdocs.yml b/gen/datastore1_beta2-cli/mkdocs.yml deleted file mode 100644 index e426001222..0000000000 --- a/gen/datastore1_beta2-cli/mkdocs.yml +++ /dev/null @@ -1,22 +0,0 @@ -site_name: datastore v0.3.5+20160314 -site_url: http://byron.github.io/google-apis-rs/google-datastore1_beta2-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/datastore1_beta2-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['datasets_allocate-ids.md', 'Datasets', 'Allocate Ids'] -- ['datasets_begin-transaction.md', 'Datasets', 'Begin Transaction'] -- ['datasets_commit.md', 'Datasets', 'Commit'] -- ['datasets_lookup.md', 'Datasets', 'Lookup'] -- ['datasets_rollback.md', 'Datasets', 'Rollback'] -- ['datasets_run-query.md', 'Datasets', 'Run Query'] - -theme: readthedocs - -copyright: Copyright © 2015-2016, `Sebastian Thiel` - diff --git a/gen/datastore1_beta2-cli/src/cmn.rs b/gen/datastore1_beta2-cli/src/cmn.rs deleted file mode 100644 index 779c1dc086..0000000000 --- a/gen/datastore1_beta2-cli/src/cmn.rs +++ /dev/null @@ -1,721 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use serde_json as json; -use serde_json::value::Value; -use mime::Mime; -use clap::{App, SubCommand}; -use strsim; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - - -pub enum ComplexType { - Pod, - Vec, - Map, -} - - // Null, - // Bool(bool), - // I64(i64), - // U64(u64), - // F64(f64), - // String(String), - -pub enum JsonType { - Boolean, - Int, - Uint, - Float, - String, -} - -pub struct JsonTypeInfo { - pub jtype: JsonType, - pub ctype: ComplexType, -} - -// Based on @erickt user comment. Thanks for the idea ! -// Remove all keys whose values are null from given value (changed in place) -pub fn remove_json_null_values(value: &mut Value) { - match *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); - } - } - _ => {} - } -} - -fn did_you_mean<'a>(v: &str, possible_values: &[&'a str]) -> Option<&'a str> { - - let mut candidate: Option<(f64, &str)> = None; - for pv in possible_values { - let confidence = strsim::jaro_winkler(v, pv); - if confidence > 0.8 && (candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence)) { - candidate = Some((confidence, pv)); - } - } - match candidate { - None => None, - Some((_, candidate)) => Some(candidate), - } -} - -pub enum CallType { - Upload(UploadProtocol), - Standard, -} - -arg_enum!{ - pub enum UploadProtocol { - Simple, - Resumable - } -} - -impl AsRef for UploadProtocol { - fn as_ref(&self) -> &str { - match *self { - UploadProtocol::Simple => "simple", - UploadProtocol::Resumable => "resumable" - } - } -} - -impl AsRef for CallType { - fn as_ref(&self) -> &str { - match *self { - CallType::Upload(ref proto) => proto.as_ref(), - CallType::Standard => "standard-request" - } - } -} - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.join(".") - } -} - -impl From<&'static str> for FieldCursor { - fn from(value: &'static str) -> FieldCursor { - let mut res = FieldCursor::default(); - res.set(value).unwrap(); - res - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn did_you_mean(value: &str, possible_values: &[&str]) -> Option { - if value.len() == 0 { - return None - } - - let mut last_c = FIELD_SEP; - - let mut field = String::new(); - let mut output = String::new(); - - let push_field = |fs: &mut String, f: &mut String| { - if f.len() > 0 { - fs.push_str( - match did_you_mean(&f, possible_values) { - Some(candidate) => candidate, - None => &f, - }); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - if c == FIELD_SEP { - if last_c != FIELD_SEP { - push_field(&mut output, &mut field); - } - output.push(c); - } else { - field.push(c); - } - - last_c = c; - } - - push_field(&mut output, &mut field); - - if &output == value { - None - } else { - Some(output) - } - } - - pub fn set_json_value(&self, mut object: &mut Value, - value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, - orig_cursor: &FieldCursor) { - assert!(self.0.len() > 0); - - for field in &self.0[..self.0.len()-1] { - let tmp = object; - object = - match *tmp { - Value::Object(ref mut mapping) => { - mapping.entry(field.to_owned()).or_insert( - Value::Object(Default::default()) - ) - }, - _ => panic!("We don't expect non-object Values here ...") - }; - } - - match *object { - Value::Object(ref mut mapping) => { - let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| - -> Value { - match jtype { - JsonType::Boolean => - Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => - Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => - Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => - Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => - Value::String(value.to_owned()), - } - }; - - match type_info.ctype { - ComplexType::Pod => { - if mapping.insert(field.to_owned(), to_jval(value, type_info.jtype, err)).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - }, - ComplexType::Vec => { - match *mapping.entry(field.to_owned()) - .or_insert(Value::Array(Default::default())) { - Value::Array(ref mut values) => values.push(to_jval(value, type_info.jtype, err)), - _ => unreachable!() - } - }, - ComplexType::Map => { - let (key, value) = parse_kv_arg(value, err, true); - let jval = to_jval(value.unwrap_or(""), type_info.jtype, err); - - match *mapping.entry(field.to_owned()) - .or_insert(Value::Object(Default::default())) { - Value::Object(ref mut value_map) => { - if value_map.insert(key.to_owned(), jval).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - } - _ => unreachable!() - } - } - } - }, - _ => unreachable!() - } - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); - match kv.find('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, Some("")) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut InvalidOptionsError) -> CallType { - CallType::Upload( - match UploadProtocol::from_str(name) { - Ok(up) => up, - Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); - UploadProtocol::Simple - } - }) -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::Io((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { - let f = arg.unwrap_or("-"); - match f { - "-" => Ok(Box::new(stdout())), - _ => match fs::OpenOptions::new().create(true).write(true).open(f) { - Ok(f) => Ok(Box::new(f)), - Err(io_err) => Err(io_err), - } - } -} - - -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, - arg_type: &'a str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError(arg_name.to_owned(), arg_type.to_owned(), arg.to_string(), format!("{}", perr)) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - type Error = json::Error; - - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Result<(), json::Error> { - match token { - None => { - match fs::remove_file(self.path(scope_hash)) { - Err(err) => - match err.kind() { - io::ErrorKind::NotFound => Ok(()), - _ => Err(json::Error::Io(err)) - }, - Ok(_) => Ok(()), - } - } - Some(token) => { - match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { - Ok(mut f) => { - match json::to_writer_pretty(&mut f, &token) { - Ok(_) => Ok(()), - Err(serde_err) => Err(serde_err), - } - }, - Err(io_err) => Err(json::Error::Io(io_err)) - } - } - } - } - - fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, json::Error> { - match fs::File::open(&self.path(scope_hash)) { - Ok(f) => { - match json::de::from_reader(f) { - Ok(token) => Ok(Some(token)), - Err(err) => Err(err), - } - }, - Err(io_err) => { - match io_err.kind() { - io::ErrorKind::NotFound => Ok(None), - _ => Err(json::Error::Io(io_err)) - } - } - } - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::Error)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - Io((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty."), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::Io((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}.", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - Io((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::Io((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}.", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type.", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String, Option, Option), - Duplicate(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor.", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character.", field), - FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = - match *suggestion { - Some(ref s) => { - let kv = - match *value { - Some(ref v) => format!("{}={}", s, v), - None => s.clone(), - }; - format!(" Did you mean '{}' ?", kv) - }, - None => String::new(), - }; - writeln!(f, "Field '{}' does not exist.{}", field, suffix) - }, - FieldError::Duplicate(ref cursor) - => writeln!(f, "Value at '{}' was already set", cursor), - FieldError::Empty - => writeln!(f, "Field names must not be empty."), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError(String, String, String, String), - UnknownParameter(String, Vec<&'static str>), - InvalidUploadProtocol(String, Vec), - InvalidKeyValueSyntax(String, bool), - Input(InputError), - Field(FieldError), - MissingCommandError, - MissingMethodError(String), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let suffix = - match did_you_mean(param_name, &possible_values) { - Some(v) => format!(" Did you mean '{}' ?", v), - None => String::new(), - }; - write!(f, "Parameter '{}' is unknown.{}\n", param_name, suffix) - }, - CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { - let hashmap_info = if is_hashmap { "hashmap " } else { "" }; - writeln!(f, "'{}' does not match {}pattern =.", kv, hashmap_info) - }, - CLIError::MissingCommandError => writeln!(f, "Please specify the main sub-command."), - CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the '{}' command.", cmd), - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, - json_console_secret: &str) - -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::Io( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret - = json::from_str(json_console_secret).unwrap(); - match json::to_writer_pretty(&mut f, &console_secret) { - Err(serde_err) => match serde_err { - json::Error::Io(err) => err, - _ => panic!("Unexpected serde error: {:#?}", serde_err) - }, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(f) => { - match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::Io(err)) => - return secret_io_error(err), - Err(json_err) => - return Err(CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::DecoderError( - (secret_str(), json_err) - )))), - Ok(console_secret) => - match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} diff --git a/gen/datastore1_beta2-cli/src/main.rs b/gen/datastore1_beta2-cli/src/main.rs deleted file mode 100644 index 06849d825a..0000000000 --- a/gen/datastore1_beta2-cli/src/main.rs +++ /dev/null @@ -1,967 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -#[macro_use] -extern crate clap; -extern crate yup_oauth2 as oauth2; -extern crate yup_hyper_mock as mock; -extern crate serde; -extern crate serde_json; -extern crate hyper; -extern crate mime; -extern crate strsim; -extern crate google_datastore1_beta2 as api; - -use std::env; -use std::io::{self, Write}; -use clap::{App, SubCommand, Arg}; - -mod cmn; - -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol, - calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, FlowType}; -use serde_json as json; -use clap::ArgMatches; - -enum DoitError { - IoError(String, io::Error), - ApiError(api::Error), -} - -struct Engine<'n> { - opt: ArgMatches<'n>, - hub: api::Datastore>, - gp: Vec<&'static str>, - gpm: Vec<(&'static str, &'static str)>, -} - - -impl<'n> Engine<'n> { - fn _datasets_allocate_ids(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec![]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::AllocateIdsRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.datasets().allocate_ids(request, opt.value_of("dataset-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _datasets_begin_transaction(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "isolation-level" => Some(("isolationLevel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["isolation-level"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::BeginTransactionRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.datasets().begin_transaction(request, opt.value_of("dataset-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _datasets_commit(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "ignore-read-only" => Some(("ignoreReadOnly", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "transaction" => Some(("transaction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "mode" => Some(("mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "mutation.force" => Some(("mutation.force", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["force", "ignore-read-only", "mode", "mutation", "transaction"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::CommitRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.datasets().commit(request, opt.value_of("dataset-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _datasets_lookup(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "read-options.transaction" => Some(("readOptions.transaction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "read-options.read-consistency" => Some(("readOptions.readConsistency", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["read-consistency", "read-options", "transaction"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::LookupRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.datasets().lookup(request, opt.value_of("dataset-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _datasets_rollback(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "transaction" => Some(("transaction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["transaction"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::RollbackRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.datasets().rollback(request, opt.value_of("dataset-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _datasets_run_query(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "query.filter.composite-filter.operator" => Some(("query.filter.compositeFilter.operator", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.operator" => Some(("query.filter.propertyFilter.operator", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.property.name" => Some(("query.filter.propertyFilter.property.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.entity-value.key.partition-id.namespace" => Some(("query.filter.propertyFilter.value.entityValue.key.partitionId.namespace", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.entity-value.key.partition-id.dataset-id" => Some(("query.filter.propertyFilter.value.entityValue.key.partitionId.datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.double-value" => Some(("query.filter.propertyFilter.value.doubleValue", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.integer-value" => Some(("query.filter.propertyFilter.value.integerValue", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.meaning" => Some(("query.filter.propertyFilter.value.meaning", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.date-time-value" => Some(("query.filter.propertyFilter.value.dateTimeValue", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.key-value.partition-id.namespace" => Some(("query.filter.propertyFilter.value.keyValue.partitionId.namespace", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.key-value.partition-id.dataset-id" => Some(("query.filter.propertyFilter.value.keyValue.partitionId.datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.string-value" => Some(("query.filter.propertyFilter.value.stringValue", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.indexed" => Some(("query.filter.propertyFilter.value.indexed", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.blob-value" => Some(("query.filter.propertyFilter.value.blobValue", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.boolean-value" => Some(("query.filter.propertyFilter.value.booleanValue", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "query.filter.property-filter.value.blob-key-value" => Some(("query.filter.propertyFilter.value.blobKeyValue", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.start-cursor" => Some(("query.startCursor", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.end-cursor" => Some(("query.endCursor", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "query.limit" => Some(("query.limit", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "query.offset" => Some(("query.offset", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "partition-id.namespace" => Some(("partitionId.namespace", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "partition-id.dataset-id" => Some(("partitionId.datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "gql-query.query-string" => Some(("gqlQuery.queryString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "gql-query.allow-literal" => Some(("gqlQuery.allowLiteral", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "read-options.transaction" => Some(("readOptions.transaction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "read-options.read-consistency" => Some(("readOptions.readConsistency", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-literal", "blob-key-value", "blob-value", "boolean-value", "composite-filter", "dataset-id", "date-time-value", "double-value", "end-cursor", "entity-value", "filter", "gql-query", "indexed", "integer-value", "key", "key-value", "limit", "meaning", "name", "namespace", "offset", "operator", "partition-id", "property", "property-filter", "query", "query-string", "read-consistency", "read-options", "start-cursor", "string-value", "transaction", "value"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::RunQueryRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.datasets().run_query(request, opt.value_of("dataset-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _doit(&self, dry_run: bool) -> Result, Option> { - let mut err = InvalidOptionsError::new(); - let mut call_result: Result<(), DoitError> = Ok(()); - let mut err_opt: Option = None; - match self.opt.subcommand() { - ("datasets", Some(opt)) => { - match opt.subcommand() { - ("allocate-ids", Some(opt)) => { - call_result = self._datasets_allocate_ids(opt, dry_run, &mut err); - }, - ("begin-transaction", Some(opt)) => { - call_result = self._datasets_begin_transaction(opt, dry_run, &mut err); - }, - ("commit", Some(opt)) => { - call_result = self._datasets_commit(opt, dry_run, &mut err); - }, - ("lookup", Some(opt)) => { - call_result = self._datasets_lookup(opt, dry_run, &mut err); - }, - ("rollback", Some(opt)) => { - call_result = self._datasets_rollback(opt, dry_run, &mut err); - }, - ("run-query", Some(opt)) => { - call_result = self._datasets_run_query(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("datasets".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - _ => { - err.issues.push(CLIError::MissingCommandError); - writeln!(io::stderr(), "{}\n", self.opt.usage()).ok(); - } - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - Err(err_opt) - } else { - Ok(call_result) - } - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: ArgMatches<'n>) -> Result, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "datastore1-beta2-secret.json", - "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, - if opt.is_present("debug-auth") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }, - JsonTokenStorage { - program_name: "datastore1-beta2", - db_dir: config_dir.clone(), - }, Some(FlowType::InstalledInteractive)); - - let client = - if opt.is_present("debug") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }; - let engine = Engine { - opt: opt, - hub: api::Datastore::new(client, auth), - gp: vec!["alt", "fields", "key", "oauth-token", "pretty-print", "quota-user", "user-ip"], - gpm: vec![ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ] - }; - - match engine._doit(true) { - Err(Some(err)) => Err(err), - Err(None) => Ok(engine), - Ok(_) => unreachable!(), - } - } - - fn doit(&self) -> Result<(), DoitError> { - match self._doit(false) { - Ok(res) => res, - Err(_) => unreachable!(), - } - } -} - -fn main() { - let mut exit_status = 0i32; - let arg_data = [ - ("datasets", "methods: 'allocate-ids', 'begin-transaction', 'commit', 'lookup', 'rollback' and 'run-query'", vec![ - ("allocate-ids", - Some(r##"Allocate IDs for incomplete keys (useful for referencing an entity before it is inserted)."##), - "Details at http://byron.github.io/google-apis-rs/google_datastore1_beta2_cli/datasets_allocate-ids", - vec![ - (Some(r##"dataset-id"##), - None, - Some(r##"Identifies the dataset."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("begin-transaction", - Some(r##"Begin a new transaction."##), - "Details at http://byron.github.io/google-apis-rs/google_datastore1_beta2_cli/datasets_begin-transaction", - vec![ - (Some(r##"dataset-id"##), - None, - Some(r##"Identifies the dataset."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("commit", - Some(r##"Commit a transaction, optionally creating, deleting or modifying some entities."##), - "Details at http://byron.github.io/google-apis-rs/google_datastore1_beta2_cli/datasets_commit", - vec![ - (Some(r##"dataset-id"##), - None, - Some(r##"Identifies the dataset."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("lookup", - Some(r##"Look up some entities by key."##), - "Details at http://byron.github.io/google-apis-rs/google_datastore1_beta2_cli/datasets_lookup", - vec![ - (Some(r##"dataset-id"##), - None, - Some(r##"Identifies the dataset."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("rollback", - Some(r##"Roll back a transaction."##), - "Details at http://byron.github.io/google-apis-rs/google_datastore1_beta2_cli/datasets_rollback", - vec![ - (Some(r##"dataset-id"##), - None, - Some(r##"Identifies the dataset."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("run-query", - Some(r##"Query for entities."##), - "Details at http://byron.github.io/google-apis-rs/google_datastore1_beta2_cli/datasets_run-query", - vec![ - (Some(r##"dataset-id"##), - None, - Some(r##"Identifies the dataset."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ]; - - let mut app = App::new("datastore1-beta2") - .author("Sebastian Thiel ") - .version("0.3.5+20160314") - .about("Stores and queries data in Google Cloud Datastore.") - .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_datastore1_beta2_cli") - .arg(Arg::with_name("url") - .long("scope") - .help("Specify the authentication a method should be executed in. Each scope requires the user to grant this application permission to use it.If unset, it defaults to the shortest scope url for a particular method.") - .multiple(true) - .takes_value(true)) - .arg(Arg::with_name("folder") - .long("config-dir") - .help("A directory into which we will store our persistent data. Defaults to a user-writable directory that we will create during the first invocation.[default: ~/.google-service-cli") - .multiple(false) - .takes_value(true)) - .arg(Arg::with_name("debug") - .long("debug") - .help("Output all server communication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)) - .arg(Arg::with_name("debug-auth") - .long("debug-auth") - .help("Output all communication related to authentication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)); - - for &(main_command_name, about, ref subcommands) in arg_data.iter() { - let mut mcmd = SubCommand::with_name(main_command_name).about(about); - - for &(sub_command_name, ref desc, url_info, ref args) in subcommands { - let mut scmd = SubCommand::with_name(sub_command_name); - if let &Some(desc) = desc { - scmd = scmd.about(desc); - } - scmd = scmd.after_help(url_info); - - for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args { - let arg_name_str = - match (arg_name, flag) { - (&Some(an), _ ) => an, - (_ , &Some(f)) => f, - _ => unreachable!(), - }; - let mut arg = Arg::with_name(arg_name_str) - .empty_values(false); - if let &Some(short_flag) = flag { - arg = arg.short(short_flag); - } - if let &Some(desc) = desc { - arg = arg.help(desc); - } - if arg_name.is_some() && flag.is_some() { - arg = arg.takes_value(true); - } - if let &Some(required) = required { - arg = arg.required(required); - } - if let &Some(multi) = multi { - arg = arg.multiple(multi); - } - scmd = scmd.arg(arg); - } - mcmd = mcmd.subcommand(scmd); - } - app = app.subcommand(mcmd); - } - - let matches = app.get_matches(); - - let debug = matches.is_present("debug"); - match Engine::new(matches) { - Err(err) => { - exit_status = err.exit_code; - writeln!(io::stderr(), "{}", err).ok(); - }, - Ok(engine) => { - if let Err(doit_err) = engine.doit() { - exit_status = 1; - match doit_err { - DoitError::IoError(path, err) => { - writeln!(io::stderr(), "Failed to open output file '{}': {}", path, err).ok(); - }, - DoitError::ApiError(err) => { - if debug { - writeln!(io::stderr(), "{:#?}", err).ok(); - } else { - writeln!(io::stderr(), "{}", err).ok(); - } - } - } - } - } - } - - std::process::exit(exit_status); -} \ No newline at end of file diff --git a/gen/datastore1_beta2/Cargo.toml b/gen/datastore1_beta2/Cargo.toml deleted file mode 100644 index 32519014cf..0000000000 --- a/gen/datastore1_beta2/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-datastore1_beta2" -version = "0.1.14+20160314" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with datastore (protocol v1beta2)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/datastore1_beta2" -homepage = "https://developers.google.com/datastore/" -documentation = "http://byron.github.io/google-apis-rs/google_datastore1_beta2" -license = "MIT" -keywords = ["datastore", "google", "protocol", "web", "api"] -build = "src/build.rs" - - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -url = "= 0.5" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - diff --git a/gen/datastore1_beta2/LICENSE.md b/gen/datastore1_beta2/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/datastore1_beta2/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/datastore1_beta2/README.md b/gen/datastore1_beta2/README.md deleted file mode 100644 index a054efb858..0000000000 --- a/gen/datastore1_beta2/README.md +++ /dev/null @@ -1,179 +0,0 @@ - -The `google-datastore1_beta2` library allows access to all features of the *Google datastore* service. - -This documentation was generated from *datastore* crate version *0.1.14+20160314*, where *20160314* is the exact revision of the *datastore:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. - -Everything else about the *datastore* *v1_beta2* API can be found at the -[official documentation site](https://developers.google.com/datastore/). -# Features - -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_datastore1_beta2/struct.Datastore.html) ... - -* datasets - * [*allocate ids*](http://byron.github.io/google-apis-rs/google_datastore1_beta2/struct.DatasetAllocateIdCall.html), [*begin transaction*](http://byron.github.io/google-apis-rs/google_datastore1_beta2/struct.DatasetBeginTransactionCall.html), [*commit*](http://byron.github.io/google-apis-rs/google_datastore1_beta2/struct.DatasetCommitCall.html), [*lookup*](http://byron.github.io/google-apis-rs/google_datastore1_beta2/struct.DatasetLookupCall.html), [*rollback*](http://byron.github.io/google-apis-rs/google_datastore1_beta2/struct.DatasetRollbackCall.html) and [*run query*](http://byron.github.io/google-apis-rs/google_datastore1_beta2/struct.DatasetRunQueryCall.html) - - - - -# Structure of this Library - -The API is structured into the following primary items: - -* **[Hub](http://byron.github.io/google-apis-rs/google_datastore1_beta2/struct.Datastore.html)** - * a central object to maintain state and allow accessing all *Activities* - * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.MethodsBuilder.html) which in turn - allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.CallBuilder.html) -* **[Resources](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.Resource.html)** - * primary types that you can apply *Activities* to - * a collection of properties and *Parts* - * **[Parts](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.Part.html)** - * a collection of properties - * never directly used in *Activities* -* **[Activities](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.CallBuilder.html)** - * 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() -``` - -Or specifically ... - -```ignore -let r = hub.datasets().lookup(...).doit() -``` - -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-datastore1_beta2 = "*" -``` - -## A complete example - -```Rust -extern crate hyper; -extern crate yup_oauth2 as oauth2; -extern crate google_datastore1_beta2 as datastore1_beta2; -use datastore1_beta2::LookupRequest; -use datastore1_beta2::{Result, Error}; -use std::default::Default; -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use datastore1_beta2::Datastore; - -// Get an ApplicationSecret instance by some means. It contains the `client_id` and -// `client_secret`, among other things. -let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - ::default(), None); -let mut hub = Datastore::new(hyper::Client::new(), 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 = LookupRequest::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.datasets().lookup(req, "datasetId") - .doit(); - -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::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](http://byron.github.io/google-apis-rs/google_datastore1_beta2/enum.Result.html) enumeration as return value of -the doit() methods, or handed as possibly intermediate results to either the -[Hub Delegate](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_datastore1_beta2/../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](http://byron.github.io/google-apis-rs/google_datastore1_beta2/enum.Result.html), should be -read by you to obtain the media. -If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.ResponseResult.html), 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](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.Delegate.html) to the -[Method Builder](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.CallBuilder.html) 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](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.Delegate.html) 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 [enocodable](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.RequestValue.html) and -[decodable](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -are valid. -Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.Part.html) 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](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.CallBuilder.html), 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](http://byron.github.io/google-apis-rs/google_datastore1_beta2/trait.RequestValue.html) 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 **datastore1_beta2** 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-rs/LICENSE.md diff --git a/gen/datastore1_beta2/src/build.rs b/gen/datastore1_beta2/src/build.rs deleted file mode 100644 index 0bebaf0bf0..0000000000 --- a/gen/datastore1_beta2/src/build.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[cfg(feature = "with-serde-codegen")] -mod inner { - extern crate serde_codegen; - - use std::env; - use std::path::Path; - - pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - - let src = Path::new("src/lib.rs.in"); - let dst = Path::new(&out_dir).join("lib.rs"); - - serde_codegen::expand(&src, &dst).unwrap(); - } -} - -#[cfg(not(feature = "with-serde-codegen"))] -mod inner { - pub fn main() {} -} - -pub fn main() { - inner::main() -} \ No newline at end of file diff --git a/gen/datastore1_beta2/src/cmn.rs b/gen/datastore1_beta2/src/cmn.rs deleted file mode 100644 index d75063e466..0000000000 --- a/gen/datastore1_beta2/src/cmn.rs +++ /dev/null @@ -1,753 +0,0 @@ -// COPY OF 'src/rust/api/cmn.rs' -// DO NOT EDIT -use std::io::{self, Read, Seek, Cursor, Write, SeekFrom}; -use std; -use std::fmt::{self, Display}; -use std::str::FromStr; -use std::error; -use std::thread::sleep; -use std::time::Duration; - -use mime::{Mime, TopLevel, SubLevel, Attr, Value}; -use oauth2::{TokenType, Retry, self}; -use hyper; -use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header, - HeaderFormat, Bearer}; -use hyper::http::h1::LINE_ENDING; -use hyper::method::Method; -use hyper::status::StatusCode; - -use serde_json as json; - -/// 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 {} -impl 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 utility type which can decode a server response that indicates error -#[derive(Deserialize)] -pub struct JsonServerError { - pub error: String, - pub error_description: Option -} - -/// A utility to represent detailed errors we might see in case there are BadRequests. -/// The latter happen if the sent parameters or request structures are unsound -#[derive(Deserialize, Serialize, Debug)] -pub struct ErrorResponse { - error: ServerError, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerError { - errors: Vec, - code: u16, - message: String, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerMessage { - domain: String, - reason: String, - message: String, - #[serde(rename="locationType")] - location_type: Option, - location: Option -} - -#[derive(Copy, Clone)] -pub struct DummyNetworkStream; - -impl Read for DummyNetworkStream { - fn read(&mut self, _: &mut [u8]) -> io::Result { - Ok(0) - } -} - -impl Write for DummyNetworkStream { - fn write(&mut self, _: &[u8]) -> io::Result { - Ok(0) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl hyper::net::NetworkStream for DummyNetworkStream { - fn peer_addr(&mut self) -> io::Result { - Ok("127.0.0.1:1337".parse().unwrap()) - } - - fn set_read_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } - - fn set_write_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } -} - - -/// 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 { - - /// 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, MethodInfo) {} - - /// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), 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, &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 { - 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: &error::Error) -> Option { - 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 { - 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::client::Response, Option, _: Option) -> 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(ErrorResponse), - - /// 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(Box), - - /// 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::client::Response), -} - - -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - 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 err) => { - try!(writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message)); - for err in err.error.errors.iter() { - try!(writeln!(f, " {}: {}, {}{}", - err.domain, - err.message, - err.reason, - match &err.location { - &Some(ref loc) => format!("@{}", loc), - &None => String::new(), - })); - } - 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 description(&self) -> &str { - match *self { - Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(_, ref err) => err.description(), - _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" - } - } - - fn cause(&self) -> Option<&error::Error> { - match *self { - Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(_, ref err) => err.cause(), - _ => None - } - } -} - -/// A universal result type used as return for all calls. -pub type Result = std::result::Result; - -/// Contains information about an API request. -pub struct MethodInfo { - pub id: &'static str, - pub http_method: Method, -} - -const BOUNDARY: &'static 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<(Headers, &'a mut Read)>, - current_part: Option<(Cursor>, &'a mut Read)>, - last_part_boundary: Option>>, -} - -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 Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> { - let mut headers = Headers::new(); - headers.set(ContentType(mime_type)); - headers.set(ContentLength(size)); - 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.len() == 0 && 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.len() == 0 && self.current_part.is_some() - } -} - -impl<'a> Read for MultiPartReader<'a> { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - 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::::new()); - (write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING, - headers, 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).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<'a>(&'a self) -> &'a Mime { &self.0 } -} -impl ::std::ops::DerefMut for XUploadContentType { - fn deref_mut<'a>(&'a mut self) -> &'a mut Mime { &mut self.0 } -} -impl Header for XUploadContentType { - fn header_name() -> &'static str { "X-Upload-Content-Type" } - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - hyper::header::parsing::from_one_raw_str(raw).map(XUploadContentType) - } -} -impl HeaderFormat for XUploadContentType { - fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&**self, f) - } -} -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 { - 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, - pub total_length: u64, -} - -impl Header for ContentRange { - fn header_name() -> &'static str { - "Content-Range" - } - - /// We are not parsable, as parsing is done by the `Range` header - fn parse_header(_: &[Vec]) -> hyper::error::Result { - Err(hyper::error::Error::Method) - } -} - - -impl HeaderFormat for ContentRange { - fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes ")); - match self.range { - Some(ref c) => try!(c.fmt(fmt)), - None => try!(fmt.write_str("*")) - } - (write!(fmt, "/{}", self.total_length)).ok(); - Ok(()) - } -} - -#[derive(Clone, PartialEq, Debug)] -pub struct RangeResponseHeader(pub Chunk); - -impl Header for RangeResponseHeader { - fn header_name() -> &'static str { - "Range" - } - - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - if raw.len() > 0 { - let v = &raw[0]; - if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes "; - if s.starts_with(PREFIX) { - if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { - return Ok(RangeResponseHeader(c)) - } - } - } - } - Err(hyper::error::Error::Method) - } -} - -impl HeaderFormat for RangeResponseHeader { - /// No implmentation necessary, we just need to parse - fn fmt_header(&self, _: &mut fmt::Formatter) -> fmt::Result { - Err(fmt::Error) - } -} - -/// A utility type to perform a resumable upload from start to end. -pub struct ResumableUploadHelper<'a, A: 'a> { - pub client: &'a mut hyper::client::Client, - pub delegate: &'a mut Delegate, - pub start_at: Option, - pub auth: &'a mut A, - pub user_agent: &'a str, - pub auth_header: Authorization, - pub url: &'a str, - pub reader: &'a mut ReadSeek, - pub media_type: Mime, - pub content_length: u64 -} - -impl<'a, A> ResumableUploadHelper<'a, A> - where A: oauth2::GetToken { - - fn query_transfer_status(&mut self) -> std::result::Result> { - loop { - match self.client.post(self.url) - .header(UserAgent(self.user_agent.to_string())) - .header(ContentRange { range: None, total_length: self.content_length }) - .header(self.auth_header.clone()) - .send() { - Ok(r) => { - // 308 = resume-incomplete == PermanentRedirect - let headers = r.headers.clone(); - let h: &RangeResponseHeader = match headers.get() { - Some(hh) if r.status == StatusCode::PermanentRedirect => hh, - None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None, 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 fn upload(&mut self) -> Option> { - let mut start = match self.start_at { - Some(s) => s, - None => match self.query_transfer_status() { - 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 - }; - - self.reader.seek(SeekFrom::Start(start)).unwrap(); - loop { - 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 range_header = ContentRange { - range: Some(Chunk {first: start, last: start + request_size - 1}), - total_length: self.content_length - }; - start += request_size; - if self.delegate.cancel_chunk_upload(&range_header) { - return None - } - let res = self.client.post(self.url) - .header(range_header) - .header(ContentType(self.media_type.clone())) - .header(UserAgent(self.user_agent.to_string())) - .body(&mut section_reader) - .send(); - match res { - Ok(mut res) => { - if res.status == StatusCode::PermanentRedirect { - continue - } - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - } - return Some(Ok(res)) - }, - Err(err) => { - if let Retry::After(d) = self.delegate.http_error(&err) { - sleep(d); - continue; - } - return Some(Err(err)) - } - } - } - } -} - -// Copy of src/rust/cli/cmn.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); - } - } - _ => {} - } -} diff --git a/gen/datastore1_beta2/src/lib.rs b/gen/datastore1_beta2/src/lib.rs deleted file mode 100644 index f38509b9eb..0000000000 --- a/gen/datastore1_beta2/src/lib.rs +++ /dev/null @@ -1,189 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.mako' -// DO NOT EDIT ! - -//! This documentation was generated from *datastore* crate version *0.1.14+20160314*, where *20160314* is the exact revision of the *datastore:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. -//! -//! Everything else about the *datastore* *v1_beta2* API can be found at the -//! [official documentation site](https://developers.google.com/datastore/). -//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/datastore1_beta2). -//! # Features -//! -//! Handle the following *Resources* with ease from the central [hub](struct.Datastore.html) ... -//! -//! * datasets -//! * [*allocate ids*](struct.DatasetAllocateIdCall.html), [*begin transaction*](struct.DatasetBeginTransactionCall.html), [*commit*](struct.DatasetCommitCall.html), [*lookup*](struct.DatasetLookupCall.html), [*rollback*](struct.DatasetRollbackCall.html) and [*run query*](struct.DatasetRunQueryCall.html) -//! -//! -//! -//! -//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html). -//! -//! # Structure of this Library -//! -//! The API is structured into the following primary items: -//! -//! * **[Hub](struct.Datastore.html)** -//! * a central object to maintain state and allow accessing all *Activities* -//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn -//! allow access to individual [*Call Builders*](trait.CallBuilder.html) -//! * **[Resources](trait.Resource.html)** -//! * primary types that you can apply *Activities* to -//! * a collection of properties and *Parts* -//! * **[Parts](trait.Part.html)** -//! * a collection of properties -//! * never directly used in *Activities* -//! * **[Activities](trait.CallBuilder.html)** -//! * 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() -//! ``` -//! -//! Or specifically ... -//! -//! ```ignore -//! let r = hub.datasets().lookup(...).doit() -//! ``` -//! -//! 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-datastore1_beta2 = "*" -//! ``` -//! -//! ## A complete example -//! -//! ```test_harness,no_run -//! extern crate hyper; -//! extern crate yup_oauth2 as oauth2; -//! extern crate google_datastore1_beta2 as datastore1_beta2; -//! use datastore1_beta2::LookupRequest; -//! use datastore1_beta2::{Result, Error}; -//! # #[test] fn egal() { -//! use std::default::Default; -//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use datastore1_beta2::Datastore; -//! -//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and -//! // `client_secret`, among other things. -//! let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -//! hyper::Client::new(), -//! ::default(), None); -//! let mut hub = Datastore::new(hyper::Client::new(), 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 = LookupRequest::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.datasets().lookup(req, "datasetId") -//! .doit(); -//! -//! 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::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](enum.Result.html) enumeration as return value of -//! the doit() methods, or handed as possibly intermediate results to either the -//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../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](enum.Result.html), should be -//! read by you to obtain the media. -//! If such a method also supports a [Response Result](trait.ResponseResult.html), 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](trait.Delegate.html) to the -//! [Method Builder](trait.CallBuilder.html) 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](trait.Delegate.html) 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 [enocodable](trait.RequestValue.html) and -//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -//! are valid. -//! Most optionals are are considered [Parts](trait.Part.html) 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](trait.CallBuilder.html), 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](trait.RequestValue.html) 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 ... . -#![cfg_attr(feature = "nightly", feature(custom_derive, custom_attribute, plugin))] -#![cfg_attr(feature = "nightly", plugin(serde_macros))] -#![allow(unused_imports, unused_mut, dead_code)] - -#[cfg(feature = "nightly")] -include!("lib.rs.in"); - -#[cfg(feature = "with-serde-codegen")] -include!(concat!(env!("OUT_DIR"), "/lib.rs")); \ No newline at end of file diff --git a/gen/datastore1_beta2/src/lib.rs.in b/gen/datastore1_beta2/src/lib.rs.in deleted file mode 100644 index 12f2410bea..0000000000 --- a/gen/datastore1_beta2/src/lib.rs.in +++ /dev/null @@ -1,2630 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.in.mako' -// DO NOT EDIT ! - -extern crate hyper; -extern crate serde; -extern crate serde_json; -extern crate yup_oauth2 as oauth2; -extern crate mime; -extern crate url; - -mod cmn; - -use std::collections::HashMap; -use std::cell::RefCell; -use std::borrow::BorrowMut; -use std::default::Default; -use std::collections::BTreeMap; -use serde_json as json; -use std::io; -use std::fs; -use std::thread::sleep; -use std::time::Duration; - -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, - ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, - Resource, ErrorResponse, remove_json_null_values}; - - -// ############## -// UTILITIES ### -// ############ - -/// Identifies the an OAuth2 authorization scope. -/// A scope is needed when requesting an -/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). -#[derive(PartialEq, Eq, Hash)] -pub enum Scope { - /// View your email address - UserinfoEmail, - - /// View and manage your Google Cloud Datastore data - Full, - - /// View and manage your data across Google Cloud Platform services - CloudPlatform, -} - -impl AsRef for Scope { - fn as_ref(&self) -> &str { - match *self { - Scope::UserinfoEmail => "https://www.googleapis.com/auth/userinfo.email", - Scope::Full => "https://www.googleapis.com/auth/datastore", - Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform", - } - } -} - -impl Default for Scope { - fn default() -> Scope { - Scope::Full - } -} - - - -// ######## -// HUB ### -// ###### - -/// Central instance to access all Datastore related resource activities -/// -/// # Examples -/// -/// Instantiate a new hub -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_datastore1_beta2 as datastore1_beta2; -/// use datastore1_beta2::LookupRequest; -/// use datastore1_beta2::{Result, Error}; -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use datastore1_beta2::Datastore; -/// -/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and -/// // `client_secret`, among other things. -/// let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Datastore::new(hyper::Client::new(), 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 = LookupRequest::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.datasets().lookup(req, "datasetId") -/// .doit(); -/// -/// 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::MissingAPIKey -/// |Error::MissingToken(_) -/// |Error::Cancelled -/// |Error::UploadSizeLimitExceeded(_, _) -/// |Error::Failure(_) -/// |Error::BadRequest(_) -/// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_, _) => println!("{}", e), -/// }, -/// Ok(res) => println!("Success: {:?}", res), -/// } -/// # } -/// ``` -pub struct Datastore { - client: RefCell, - auth: RefCell, - _user_agent: String, -} - -impl<'a, C, A> Hub for Datastore {} - -impl<'a, C, A> Datastore - where C: BorrowMut, A: oauth2::GetToken { - - pub fn new(client: C, authenticator: A) -> Datastore { - Datastore { - client: RefCell::new(client), - auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.14".to_string(), - } - } - - pub fn datasets(&'a self) -> DatasetMethods<'a, C, A> { - DatasetMethods { hub: &self } - } - - /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.14`. - /// - /// Returns the previously set user-agent. - pub fn user_agent(&mut self, agent_name: String) -> String { - let prev = self._user_agent.clone(); - self._user_agent = agent_name; - prev - } -} - - -// ############ -// SCHEMAS ### -// ########## -/// An identifier for a particular subset of entities. -/// -/// Entities are partitioned into various subsets, each used by different datasets and different namespaces within a dataset and so forth. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PartitionId { - /// The namespace. - pub namespace: Option, - /// The dataset ID. - #[serde(rename="datasetId")] - pub dataset_id: Option, -} - -impl Part for PartitionId {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [allocate ids datasets](struct.DatasetAllocateIdCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AllocateIdsResponse { - /// The keys specified in the request (in the same order), each with its key path completed with a newly allocated ID. - pub keys: Option>, - /// no description provided - pub header: Option, -} - -impl ResponseResult for AllocateIdsResponse {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [lookup datasets](struct.DatasetLookupCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct LookupRequest { - /// Keys of entities to look up from the datastore. - pub keys: Option>, - /// Options for this lookup request. Optional. - #[serde(rename="readOptions")] - pub read_options: Option, -} - -impl RequestValue for LookupRequest {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [begin transaction datasets](struct.DatasetBeginTransactionCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct BeginTransactionResponse { - /// no description provided - pub header: Option, - /// The transaction identifier (always present). - pub transaction: Option, -} - -impl ResponseResult for BeginTransactionResponse {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [allocate ids datasets](struct.DatasetAllocateIdCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AllocateIdsRequest { - /// A list of keys with incomplete key paths to allocate IDs for. No key may be reserved/read-only. - pub keys: Option>, -} - -impl RequestValue for AllocateIdsRequest {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [run query datasets](struct.DatasetRunQueryCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RunQueryResponse { - /// no description provided - pub header: Option, - /// A batch of query results (always present). - pub batch: Option, -} - -impl ResponseResult for RunQueryResponse {} - - -/// A set of changes to apply. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Mutation { - /// Entities to insert. Each inserted entity's key must have a complete path and must not be reserved/read-only. - pub insert: Option>, - /// Ignore a user specified read-only period. Optional. - pub force: Option, - /// Insert entities with a newly allocated ID. Each inserted entity's key must omit the final identifier in its path and must not be reserved/read-only. - #[serde(rename="insertAutoId")] - pub insert_auto_id: Option>, - /// Keys of entities to delete. Each key must have a complete key path and must not be reserved/read-only. - pub delete: Option>, - /// Entities to update. Each updated entity's key must have a complete path and must not be reserved/read-only. - pub update: Option>, - /// Entities to upsert. Each upserted entity's key must have a complete path and must not be reserved/read-only. - pub upsert: Option>, -} - -impl Part for Mutation {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [commit datasets](struct.DatasetCommitCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CommitResponse { - /// no description provided - pub header: Option, - /// The result of performing the mutation (if any). - #[serde(rename="mutationResult")] - pub mutation_result: Option, -} - -impl ResponseResult for CommitResponse {} - - -/// A batch of results produced by a query. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct QueryResultBatch { - /// The state of the query after the current batch. One of notFinished, moreResultsAfterLimit, noMoreResults. - #[serde(rename="moreResults")] - pub more_results: Option, - /// The number of results skipped because of Query.offset. - #[serde(rename="skippedResults")] - pub skipped_results: Option, - /// A cursor that points to the position after the last result in the batch. May be absent. TODO(arfuller): Once all plans produce cursors update documentation here. - #[serde(rename="endCursor")] - pub end_cursor: Option, - /// The results for this batch. - #[serde(rename="entityResults")] - pub entity_results: Option>, - /// The result type for every entity in entityResults. full for full entities, projection for entities with only projected properties, keyOnly for entities with only a key. - #[serde(rename="entityResultType")] - pub entity_result_type: Option, -} - -impl Part for QueryResultBatch {} - - -/// A reference to a property relative to the kind expressions. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PropertyReference { - /// The name of the property. - pub name: Option, -} - -impl Part for PropertyReference {} - - -/// The result of fetching an entity from the datastore. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct EntityResult { - /// The resulting entity. - pub entity: Option, -} - -impl Part for EntityResult {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [rollback datasets](struct.DatasetRollbackCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RollbackResponse { - /// no description provided - pub header: Option, -} - -impl ResponseResult for RollbackResponse {} - - -/// A GQL query. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct GqlQuery { - /// When false, the query string must not contain a literal. - #[serde(rename="allowLiteral")] - pub allow_literal: Option, - /// A named argument must set field GqlQueryArg.name. No two named arguments may have the same name. For each non-reserved named binding site in the query string, there must be a named argument with that name, but not necessarily the inverse. - #[serde(rename="nameArgs")] - pub name_args: Option>, - /// The query string. - #[serde(rename="queryString")] - pub query_string: Option, - /// Numbered binding site @1 references the first numbered argument, effectively using 1-based indexing, rather than the usual 0. A numbered argument must NOT set field GqlQueryArg.name. For each binding site numbered i in query_string, there must be an ith numbered argument. The inverse must also be true. - #[serde(rename="numberArgs")] - pub number_args: Option>, -} - -impl Part for GqlQuery {} - - -/// A unique identifier for an entity. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Key { - /// The entity path. An entity path consists of one or more elements composed of a kind and a string or numerical identifier, which identify entities. The first element identifies a root entity, the second element identifies a child of the root entity, the third element a child of the second entity, and so forth. The entities identified by all prefixes of the path are called the element's ancestors. An entity path is always fully complete: ALL of the entity's ancestors are required to be in the path along with the entity identifier itself. The only exception is that in some documented cases, the identifier in the last path element (for the entity) itself may be omitted. A path can never be empty. The path can have at most 100 elements. - pub path: Option>, - /// Entities are partitioned into subsets, currently identified by a dataset (usually implicitly specified by the project) and namespace ID. Queries are scoped to a single partition. - #[serde(rename="partitionId")] - pub partition_id: Option, -} - -impl Part for Key {} - - -/// A representation of a property in a projection. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PropertyExpression { - /// The aggregation function to apply to the property. Optional. Can only be used when grouping by at least one property. Must then be set on all properties in the projection that are not being grouped by. Aggregation functions: first selects the first result as determined by the query's order. - #[serde(rename="aggregationFunction")] - pub aggregation_function: Option, - /// The property to project. - pub property: Option, -} - -impl Part for PropertyExpression {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MutationResult { - /// Keys for insertAutoId entities. One per entity from the request, in the same order. - #[serde(rename="insertAutoIdKeys")] - pub insert_auto_id_keys: Option>, - /// Number of index writes. - #[serde(rename="indexUpdates")] - pub index_updates: Option, -} - -impl Part for MutationResult {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ReadOptions { - /// The transaction to use. Optional. - pub transaction: Option, - /// The read consistency to use. One of default, strong, or eventual. Cannot be set when transaction is set. Lookup and ancestor queries default to strong, global queries default to eventual and cannot be set to strong. Optional. Default is default. - #[serde(rename="readConsistency")] - pub read_consistency: Option, -} - -impl Part for ReadOptions {} - - -/// A filter on a specific property. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PropertyFilter { - /// The operator to filter by. One of lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual, equal, or hasAncestor. - pub operator: Option, - /// The property to filter by. - pub property: Option, - /// The value to compare the property to. - pub value: Option, -} - -impl Part for PropertyFilter {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ResponseHeader { - /// Identifies what kind of resource this is. Value: the fixed string "datastore#responseHeader". - pub kind: Option, -} - -impl Part for ResponseHeader {} - - -/// A message that can hold any of the supported value types and associated metadata. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Value { - /// An entity value. May have no key. May have a key with an incomplete key path. May have a reserved/read-only key. - #[serde(rename="entityValue")] - pub entity_value: Option, - /// A double value. - #[serde(rename="doubleValue")] - pub double_value: Option, - /// A blob key value. - #[serde(rename="blobKeyValue")] - pub blob_key_value: Option, - /// The meaning field is reserved and should not be used. - pub meaning: Option, - /// A timestamp value. - #[serde(rename="dateTimeValue")] - pub date_time_value: Option, - /// A key value. - #[serde(rename="keyValue")] - pub key_value: Option, - /// A blob value. May be a maximum of 1,000,000 bytes. When indexed is true, may have at most 500 bytes. - #[serde(rename="blobValue")] - pub blob_value: Option, - /// If the value should be indexed. - /// - /// The indexed property may be set for a null value. When indexed is true, stringValue is limited to 500 characters and the blob value is limited to 500 bytes. Input values by default have indexed set to true; however, you can explicitly set indexed to true if you want. (An output value never has indexed explicitly set to true.) If a value is itself an entity, it cannot have indexed set to true. - pub indexed: Option, - /// A UTF-8 encoded string value. When indexed is true, may have at most 500 characters. - #[serde(rename="stringValue")] - pub string_value: Option, - /// A list value. Cannot contain another list value. A Value instance that sets field list_value must not set field meaning or field indexed. - #[serde(rename="listValue")] - pub list_value: Option>, - /// A boolean value. - #[serde(rename="booleanValue")] - pub boolean_value: Option, - /// An integer value. - #[serde(rename="integerValue")] - pub integer_value: Option, -} - -impl Part for Value {} - - -/// A holder for any type of filter. Exactly one field should be specified. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Filter { - /// A composite filter. - #[serde(rename="compositeFilter")] - pub composite_filter: Option, - /// A filter on a property. - #[serde(rename="propertyFilter")] - pub property_filter: Option, -} - -impl Part for Filter {} - - -/// A (kind, ID/name) pair used to construct a key path. -/// -/// At most one of name or ID may be set. If either is set, the element is complete. If neither is set, the element is incomplete. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct KeyPathElement { - /// The kind of the entity. A kind matching regex "__.*__" is reserved/read-only. A kind must not contain more than 500 characters. Cannot be "". - pub kind: Option, - /// The ID of the entity. Never equal to zero. Values less than zero are discouraged and will not be supported in the future. - pub id: Option, - /// The name of the entity. A name matching regex "__.*__" is reserved/read-only. A name must not be more than 500 characters. Cannot be "". - pub name: Option, -} - -impl Part for KeyPathElement {} - - -/// An entity property. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Property { - /// An entity value. May have no key. May have a key with an incomplete key path. May have a reserved/read-only key. - #[serde(rename="entityValue")] - pub entity_value: Option, - /// A double value. - #[serde(rename="doubleValue")] - pub double_value: Option, - /// A blob key value. - #[serde(rename="blobKeyValue")] - pub blob_key_value: Option, - /// The meaning field is reserved and should not be used. - pub meaning: Option, - /// A timestamp value. - #[serde(rename="dateTimeValue")] - pub date_time_value: Option, - /// A key value. - #[serde(rename="keyValue")] - pub key_value: Option, - /// A blob value. May be a maximum of 1,000,000 bytes. When indexed is true, may have at most 500 bytes. - #[serde(rename="blobValue")] - pub blob_value: Option, - /// If the value should be indexed. - /// - /// The indexed property may be set for a null value. When indexed is true, stringValue is limited to 500 characters and the blob value is limited to 500 bytes. Input values by default have indexed set to true; however, you can explicitly set indexed to true if you want. (An output value never has indexed explicitly set to true.) If a value is itself an entity, it cannot have indexed set to true. - pub indexed: Option, - /// A UTF-8 encoded string value. When indexed is true, may have at most 500 characters. - #[serde(rename="stringValue")] - pub string_value: Option, - /// A list value. Cannot contain another list value. A Value instance that sets field list_value must not set field meaning or field indexed. - #[serde(rename="listValue")] - pub list_value: Option>, - /// A boolean value. - #[serde(rename="booleanValue")] - pub boolean_value: Option, - /// An integer value. - #[serde(rename="integerValue")] - pub integer_value: Option, -} - -impl Part for Property {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [lookup datasets](struct.DatasetLookupCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct LookupResponse { - /// Entities found. - pub found: Option>, - /// no description provided - pub header: Option, - /// A list of keys that were not looked up due to resource constraints. - pub deferred: Option>, - /// Entities not found, with only the key populated. - pub missing: Option>, -} - -impl ResponseResult for LookupResponse {} - - -/// A filter that merges the multiple other filters using the given operation. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CompositeFilter { - /// The operator for combining multiple filters. Only "and" is currently supported. - pub operator: Option, - /// The list of filters to combine. Must contain at least one filter. - pub filters: Option>, -} - -impl Part for CompositeFilter {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [commit datasets](struct.DatasetCommitCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CommitRequest { - /// no description provided - #[serde(rename="ignoreReadOnly")] - pub ignore_read_only: Option, - /// The transaction identifier, returned by a call to beginTransaction. Must be set when mode is TRANSACTIONAL. - pub transaction: Option, - /// The type of commit to perform. Either TRANSACTIONAL or NON_TRANSACTIONAL. - pub mode: Option, - /// The mutation to perform. Optional. - pub mutation: Option, -} - -impl RequestValue for CommitRequest {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [run query datasets](struct.DatasetRunQueryCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RunQueryRequest { - /// The query to run. Either this field or field gql_query must be set, but not both. - pub query: Option, - /// Entities are partitioned into subsets, identified by a dataset (usually implicitly specified by the project) and namespace ID. Queries are scoped to a single partition. This partition ID is normalized with the standard default context partition ID, but all other partition IDs in RunQueryRequest are normalized with this partition ID as the context partition ID. - #[serde(rename="partitionId")] - pub partition_id: Option, - /// The GQL query to run. Either this field or field query must be set, but not both. - #[serde(rename="gqlQuery")] - pub gql_query: Option, - /// The options for this query. - #[serde(rename="readOptions")] - pub read_options: Option, -} - -impl RequestValue for RunQueryRequest {} - - -/// A representation of a kind. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct KindExpression { - /// The name of the kind. - pub name: Option, -} - -impl Part for KindExpression {} - - -/// A binding argument for a GQL query. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct GqlQueryArg { - /// no description provided - pub cursor: Option, - /// Must match regex "[A-Za-z_$][A-Za-z_$0-9]*". Must not match regex "__.*__". Must not be "". - pub name: Option, - /// no description provided - pub value: Option, -} - -impl Part for GqlQueryArg {} - - -/// An entity. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Entity { - /// The entity's properties. - pub properties: Option>, - /// The entity's key. - /// - /// An entity must have a key, unless otherwise documented (for example, an entity in Value.entityValue may have no key). An entity's kind is its key's path's last element's kind, or null if it has no key. - pub key: Option, -} - -impl Part for Entity {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [rollback datasets](struct.DatasetRollbackCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct RollbackRequest { - /// The transaction identifier, returned by a call to beginTransaction. - pub transaction: Option, -} - -impl RequestValue for RollbackRequest {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [begin transaction datasets](struct.DatasetBeginTransactionCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct BeginTransactionRequest { - /// The transaction isolation level. Either snapshot or serializable. The default isolation level is snapshot isolation, which means that another transaction may not concurrently modify the data that is modified by this transaction. Optionally, a transaction can request to be made serializable which means that another transaction cannot concurrently modify the data that is read or modified by this transaction. - #[serde(rename="isolationLevel")] - pub isolation_level: Option, -} - -impl RequestValue for BeginTransactionRequest {} - - -/// The desired order for a specific property. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PropertyOrder { - /// The direction to order by. One of ascending or descending. Optional, defaults to ascending. - pub direction: Option, - /// The property to order by. - pub property: Option, -} - -impl Part for PropertyOrder {} - - -/// A query. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Query { - /// A starting point for the query results. Optional. Query cursors are returned in query result batches. - #[serde(rename="startCursor")] - pub start_cursor: Option, - /// The kinds to query (if empty, returns entities from all kinds). - pub kinds: Option>, - /// The projection to return. If not set the entire entity is returned. - pub projection: Option>, - /// The properties to group by (if empty, no grouping is applied to the result set). - #[serde(rename="groupBy")] - pub group_by: Option>, - /// The filter to apply (optional). - pub filter: Option, - /// The maximum number of results to return. Applies after all other constraints. Optional. - pub limit: Option, - /// The number of results to skip. Applies before limit, but after all other constraints (optional, defaults to 0). - pub offset: Option, - /// An ending point for the query results. Optional. Query cursors are returned in query result batches. - #[serde(rename="endCursor")] - pub end_cursor: Option, - /// The order to apply to the query results (if empty, order is unspecified). - pub order: Option>, -} - -impl Part for Query {} - - - -// ################### -// MethodBuilders ### -// ################# - -/// A builder providing access to all methods supported on *dataset* resources. -/// It is not used directly, but through the `Datastore` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_datastore1_beta2 as datastore1_beta2; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use datastore1_beta2::Datastore; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Datastore::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `allocate_ids(...)`, `begin_transaction(...)`, `commit(...)`, `lookup(...)`, `rollback(...)` and `run_query(...)` -/// // to build up your call. -/// let rb = hub.datasets(); -/// # } -/// ``` -pub struct DatasetMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Datastore, -} - -impl<'a, C, A> MethodsBuilder for DatasetMethods<'a, C, A> {} - -impl<'a, C, A> DatasetMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Commit a transaction, optionally creating, deleting or modifying some entities. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `datasetId` - Identifies the dataset. - pub fn commit(&self, request: CommitRequest, dataset_id: &str) -> DatasetCommitCall<'a, C, A> { - DatasetCommitCall { - hub: self.hub, - _request: request, - _dataset_id: dataset_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Allocate IDs for incomplete keys (useful for referencing an entity before it is inserted). - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `datasetId` - Identifies the dataset. - pub fn allocate_ids(&self, request: AllocateIdsRequest, dataset_id: &str) -> DatasetAllocateIdCall<'a, C, A> { - DatasetAllocateIdCall { - hub: self.hub, - _request: request, - _dataset_id: dataset_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Roll back a transaction. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `datasetId` - Identifies the dataset. - pub fn rollback(&self, request: RollbackRequest, dataset_id: &str) -> DatasetRollbackCall<'a, C, A> { - DatasetRollbackCall { - hub: self.hub, - _request: request, - _dataset_id: dataset_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Look up some entities by key. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `datasetId` - Identifies the dataset. - pub fn lookup(&self, request: LookupRequest, dataset_id: &str) -> DatasetLookupCall<'a, C, A> { - DatasetLookupCall { - hub: self.hub, - _request: request, - _dataset_id: dataset_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Query for entities. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `datasetId` - Identifies the dataset. - pub fn run_query(&self, request: RunQueryRequest, dataset_id: &str) -> DatasetRunQueryCall<'a, C, A> { - DatasetRunQueryCall { - hub: self.hub, - _request: request, - _dataset_id: dataset_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Begin a new transaction. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `datasetId` - Identifies the dataset. - pub fn begin_transaction(&self, request: BeginTransactionRequest, dataset_id: &str) -> DatasetBeginTransactionCall<'a, C, A> { - DatasetBeginTransactionCall { - hub: self.hub, - _request: request, - _dataset_id: dataset_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - - - -// ################### -// CallBuilders ### -// ################# - -/// Commit a transaction, optionally creating, deleting or modifying some entities. -/// -/// A builder for the *commit* method supported by a *dataset* resource. -/// It is not used directly, but through a `DatasetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_datastore1_beta2 as datastore1_beta2; -/// use datastore1_beta2::CommitRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use datastore1_beta2::Datastore; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Datastore::new(hyper::Client::new(), 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 = CommitRequest::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.datasets().commit(req, "datasetId") -/// .doit(); -/// # } -/// ``` -pub struct DatasetCommitCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Datastore, - _request: CommitRequest, - _dataset_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DatasetCommitCall<'a, C, A> {} - -impl<'a, C, A> DatasetCommitCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, CommitResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "datastore.datasets.commit", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("datasetId", self._dataset_id.to_string())); - for &field in ["alt", "datasetId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/datastore/v1beta2/datasets/{datasetId}/commit".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{datasetId}", "datasetId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["datasetId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: CommitRequest) -> DatasetCommitCall<'a, C, A> { - self._request = new_value; - self - } - /// Identifies the dataset. - /// - /// Sets the *dataset id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn dataset_id(mut self, new_value: &str) -> DatasetCommitCall<'a, C, A> { - self._dataset_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DatasetCommitCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DatasetCommitCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DatasetCommitCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Allocate IDs for incomplete keys (useful for referencing an entity before it is inserted). -/// -/// A builder for the *allocateIds* method supported by a *dataset* resource. -/// It is not used directly, but through a `DatasetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_datastore1_beta2 as datastore1_beta2; -/// use datastore1_beta2::AllocateIdsRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use datastore1_beta2::Datastore; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Datastore::new(hyper::Client::new(), 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 = AllocateIdsRequest::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.datasets().allocate_ids(req, "datasetId") -/// .doit(); -/// # } -/// ``` -pub struct DatasetAllocateIdCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Datastore, - _request: AllocateIdsRequest, - _dataset_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DatasetAllocateIdCall<'a, C, A> {} - -impl<'a, C, A> DatasetAllocateIdCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, AllocateIdsResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "datastore.datasets.allocateIds", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("datasetId", self._dataset_id.to_string())); - for &field in ["alt", "datasetId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/datastore/v1beta2/datasets/{datasetId}/allocateIds".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{datasetId}", "datasetId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["datasetId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: AllocateIdsRequest) -> DatasetAllocateIdCall<'a, C, A> { - self._request = new_value; - self - } - /// Identifies the dataset. - /// - /// Sets the *dataset id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn dataset_id(mut self, new_value: &str) -> DatasetAllocateIdCall<'a, C, A> { - self._dataset_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DatasetAllocateIdCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DatasetAllocateIdCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DatasetAllocateIdCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Roll back a transaction. -/// -/// A builder for the *rollback* method supported by a *dataset* resource. -/// It is not used directly, but through a `DatasetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_datastore1_beta2 as datastore1_beta2; -/// use datastore1_beta2::RollbackRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use datastore1_beta2::Datastore; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Datastore::new(hyper::Client::new(), 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 = RollbackRequest::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.datasets().rollback(req, "datasetId") -/// .doit(); -/// # } -/// ``` -pub struct DatasetRollbackCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Datastore, - _request: RollbackRequest, - _dataset_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DatasetRollbackCall<'a, C, A> {} - -impl<'a, C, A> DatasetRollbackCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, RollbackResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "datastore.datasets.rollback", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("datasetId", self._dataset_id.to_string())); - for &field in ["alt", "datasetId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/datastore/v1beta2/datasets/{datasetId}/rollback".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{datasetId}", "datasetId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["datasetId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: RollbackRequest) -> DatasetRollbackCall<'a, C, A> { - self._request = new_value; - self - } - /// Identifies the dataset. - /// - /// Sets the *dataset id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn dataset_id(mut self, new_value: &str) -> DatasetRollbackCall<'a, C, A> { - self._dataset_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DatasetRollbackCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DatasetRollbackCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DatasetRollbackCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Look up some entities by key. -/// -/// A builder for the *lookup* method supported by a *dataset* resource. -/// It is not used directly, but through a `DatasetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_datastore1_beta2 as datastore1_beta2; -/// use datastore1_beta2::LookupRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use datastore1_beta2::Datastore; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Datastore::new(hyper::Client::new(), 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 = LookupRequest::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.datasets().lookup(req, "datasetId") -/// .doit(); -/// # } -/// ``` -pub struct DatasetLookupCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Datastore, - _request: LookupRequest, - _dataset_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DatasetLookupCall<'a, C, A> {} - -impl<'a, C, A> DatasetLookupCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, LookupResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "datastore.datasets.lookup", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("datasetId", self._dataset_id.to_string())); - for &field in ["alt", "datasetId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/datastore/v1beta2/datasets/{datasetId}/lookup".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{datasetId}", "datasetId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["datasetId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: LookupRequest) -> DatasetLookupCall<'a, C, A> { - self._request = new_value; - self - } - /// Identifies the dataset. - /// - /// Sets the *dataset id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn dataset_id(mut self, new_value: &str) -> DatasetLookupCall<'a, C, A> { - self._dataset_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DatasetLookupCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DatasetLookupCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DatasetLookupCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Query for entities. -/// -/// A builder for the *runQuery* method supported by a *dataset* resource. -/// It is not used directly, but through a `DatasetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_datastore1_beta2 as datastore1_beta2; -/// use datastore1_beta2::RunQueryRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use datastore1_beta2::Datastore; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Datastore::new(hyper::Client::new(), 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 = RunQueryRequest::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.datasets().run_query(req, "datasetId") -/// .doit(); -/// # } -/// ``` -pub struct DatasetRunQueryCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Datastore, - _request: RunQueryRequest, - _dataset_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DatasetRunQueryCall<'a, C, A> {} - -impl<'a, C, A> DatasetRunQueryCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, RunQueryResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "datastore.datasets.runQuery", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("datasetId", self._dataset_id.to_string())); - for &field in ["alt", "datasetId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/datastore/v1beta2/datasets/{datasetId}/runQuery".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{datasetId}", "datasetId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["datasetId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: RunQueryRequest) -> DatasetRunQueryCall<'a, C, A> { - self._request = new_value; - self - } - /// Identifies the dataset. - /// - /// Sets the *dataset id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn dataset_id(mut self, new_value: &str) -> DatasetRunQueryCall<'a, C, A> { - self._dataset_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DatasetRunQueryCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DatasetRunQueryCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DatasetRunQueryCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Begin a new transaction. -/// -/// A builder for the *beginTransaction* method supported by a *dataset* resource. -/// It is not used directly, but through a `DatasetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_datastore1_beta2 as datastore1_beta2; -/// use datastore1_beta2::BeginTransactionRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use datastore1_beta2::Datastore; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Datastore::new(hyper::Client::new(), 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 = BeginTransactionRequest::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.datasets().begin_transaction(req, "datasetId") -/// .doit(); -/// # } -/// ``` -pub struct DatasetBeginTransactionCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Datastore, - _request: BeginTransactionRequest, - _dataset_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DatasetBeginTransactionCall<'a, C, A> {} - -impl<'a, C, A> DatasetBeginTransactionCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, BeginTransactionResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "datastore.datasets.beginTransaction", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("datasetId", self._dataset_id.to_string())); - for &field in ["alt", "datasetId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/datastore/v1beta2/datasets/{datasetId}/beginTransaction".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{datasetId}", "datasetId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["datasetId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: BeginTransactionRequest) -> DatasetBeginTransactionCall<'a, C, A> { - self._request = new_value; - self - } - /// Identifies the dataset. - /// - /// Sets the *dataset id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn dataset_id(mut self, new_value: &str) -> DatasetBeginTransactionCall<'a, C, A> { - self._dataset_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DatasetBeginTransactionCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> DatasetBeginTransactionCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> DatasetBeginTransactionCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - diff --git a/gen/deploymentmanager2-cli/Cargo.toml b/gen/deploymentmanager2-cli/Cargo.toml index e4a20f96ec..2135804934 100644 --- a/gen/deploymentmanager2-cli/Cargo.toml +++ b/gen/deploymentmanager2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-deploymentmanager2-cli" -version = "0.3.6+20160901" +version = "1.0.0+20160901" authors = ["Sebastian Thiel "] description = "A complete library to interact with Deployment Manager (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/deploymentmanager2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-deploymentmanager2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-deploymentmanager2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-deploymentmanager2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-deploymentmanager2] path = "../deploymentmanager2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/deploymentmanager2-cli/README.md b/gen/deploymentmanager2-cli/README.md index 45f91e50a8..f8a6d7d201 100644 --- a/gen/deploymentmanager2-cli/README.md +++ b/gen/deploymentmanager2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Deployment Manager* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/deploymentmanager2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/deploymentmanager2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/deploymentmanager2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/deploymentmanager2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/deploymentmanager2-cli). # Usage -This documentation was generated from the *Deployment Manager* API at revision *20160901*. The CLI is at version *0.3.6*. +This documentation was generated from the *Deployment Manager* API at revision *20160901*. The CLI is at version *1.0.0*. ```bash deploymentmanager2 [options] diff --git a/gen/deploymentmanager2-cli/mkdocs.yml b/gen/deploymentmanager2-cli/mkdocs.yml index 5809b75faf..342a44f57b 100644 --- a/gen/deploymentmanager2-cli/mkdocs.yml +++ b/gen/deploymentmanager2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Deployment Manager v0.3.6+20160901 +site_name: Deployment Manager v1.0.0+20160901 site_url: http://byron.github.io/google-apis-rs/google-deploymentmanager2-cli site_description: Write integrating applications with bcore diff --git a/gen/deploymentmanager2-cli/src/main.rs b/gen/deploymentmanager2-cli/src/main.rs index 5d66f6322d..89399ae944 100644 --- a/gen/deploymentmanager2-cli/src/main.rs +++ b/gen/deploymentmanager2-cli/src/main.rs @@ -1780,7 +1780,7 @@ fn main() { let mut app = App::new("deploymentmanager2") .author("Sebastian Thiel ") - .version("0.3.6+20160901") + .version("1.0.0+20160901") .about("Declares, configures, and deploys complex solutions on Google Cloud Platform.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_deploymentmanager2_cli") .arg(Arg::with_name("url") diff --git a/gen/deploymentmanager2_beta2-cli/Cargo.toml b/gen/deploymentmanager2_beta2-cli/Cargo.toml index 45f53fa20b..f0d805858c 100644 --- a/gen/deploymentmanager2_beta2-cli/Cargo.toml +++ b/gen/deploymentmanager2_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-deploymentmanager2_beta2-cli" -version = "0.3.6+20160201" +version = "1.0.0+20160201" authors = ["Sebastian Thiel "] description = "A complete library to interact with Deployment Manager (protocol v2beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/deploymentmanager2_beta2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-deploymentmanager2_beta2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-deploymentmanager2_beta2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-deploymentmanager2_beta2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-deploymentmanager2_beta2] path = "../deploymentmanager2_beta2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/deploymentmanager2_beta2-cli/README.md b/gen/deploymentmanager2_beta2-cli/README.md index c3055c91fd..d61290c012 100644 --- a/gen/deploymentmanager2_beta2-cli/README.md +++ b/gen/deploymentmanager2_beta2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Deployment Manager* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/deploymentmanager2-beta2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/deploymentmanager2-beta2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/deploymentmanager2-beta2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/deploymentmanager2-beta2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/deploymentmanager2_beta2-cli). # Usage -This documentation was generated from the *Deployment Manager* API at revision *20160201*. The CLI is at version *0.3.6*. +This documentation was generated from the *Deployment Manager* API at revision *20160201*. The CLI is at version *1.0.0*. ```bash deploymentmanager2-beta2 [options] diff --git a/gen/deploymentmanager2_beta2-cli/mkdocs.yml b/gen/deploymentmanager2_beta2-cli/mkdocs.yml index f2af493fe3..6ffe5da9a0 100644 --- a/gen/deploymentmanager2_beta2-cli/mkdocs.yml +++ b/gen/deploymentmanager2_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Deployment Manager v0.3.6+20160201 +site_name: Deployment Manager v1.0.0+20160201 site_url: http://byron.github.io/google-apis-rs/google-deploymentmanager2_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/deploymentmanager2_beta2-cli/src/main.rs b/gen/deploymentmanager2_beta2-cli/src/main.rs index f1122924b5..45bcfa842c 100644 --- a/gen/deploymentmanager2_beta2-cli/src/main.rs +++ b/gen/deploymentmanager2_beta2-cli/src/main.rs @@ -1478,7 +1478,7 @@ fn main() { let mut app = App::new("deploymentmanager2-beta2") .author("Sebastian Thiel ") - .version("0.3.6+20160201") + .version("1.0.0+20160201") .about("The Deployment Manager API allows users to declaratively configure, deploy and run complex solutions on the Google Cloud Platform.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli") .arg(Arg::with_name("url") diff --git a/gen/dfareporting2d1-cli/Cargo.toml b/gen/dfareporting2d1-cli/Cargo.toml index 2302ac59c0..9c058a1d09 100644 --- a/gen/dfareporting2d1-cli/Cargo.toml +++ b/gen/dfareporting2d1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d1-cli" -version = "0.3.6+20160323" +version = "1.0.0+20160323" authors = ["Sebastian Thiel "] description = "A complete library to interact with dfareporting (protocol v2.1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-dfareporting2d1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dfareporting2d1] path = "../dfareporting2d1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/dfareporting2d1-cli/README.md b/gen/dfareporting2d1-cli/README.md index 94d7abb6b0..e756cbc02d 100644 --- a/gen/dfareporting2d1-cli/README.md +++ b/gen/dfareporting2d1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *dfareporting* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/dfareporting2d1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/dfareporting2d1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/dfareporting2d1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/dfareporting2d1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d1-cli). # Usage -This documentation was generated from the *dfareporting* API at revision *20160323*. The CLI is at version *0.3.6*. +This documentation was generated from the *dfareporting* API at revision *20160323*. The CLI is at version *1.0.0*. ```bash dfareporting2d1 [options] diff --git a/gen/dfareporting2d1-cli/mkdocs.yml b/gen/dfareporting2d1-cli/mkdocs.yml index f5f6915f0d..328200c0ba 100644 --- a/gen/dfareporting2d1-cli/mkdocs.yml +++ b/gen/dfareporting2d1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dfareporting v0.3.6+20160323 +site_name: dfareporting v1.0.0+20160323 site_url: http://byron.github.io/google-apis-rs/google-dfareporting2d1-cli site_description: Write integrating applications with bcore diff --git a/gen/dfareporting2d1-cli/src/main.rs b/gen/dfareporting2d1-cli/src/main.rs index baa9a31ec6..27ae5d462f 100644 --- a/gen/dfareporting2d1-cli/src/main.rs +++ b/gen/dfareporting2d1-cli/src/main.rs @@ -22314,7 +22314,7 @@ fn main() { let mut app = App::new("dfareporting2d1") .author("Sebastian Thiel ") - .version("0.3.6+20160323") + .version("1.0.0+20160323") .about("Manages your DoubleClick Campaign Manager ad campaigns and reports.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_dfareporting2d1_cli") .arg(Arg::with_name("url") diff --git a/gen/dfareporting2d2-cli/Cargo.toml b/gen/dfareporting2d2-cli/Cargo.toml index a31be4cd1b..755af97f5d 100644 --- a/gen/dfareporting2d2-cli/Cargo.toml +++ b/gen/dfareporting2d2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d2-cli" -version = "0.3.6+20160803" +version = "1.0.0+20160803" authors = ["Sebastian Thiel "] description = "A complete library to interact with dfareporting (protocol v2.2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-dfareporting2d2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dfareporting2d2] path = "../dfareporting2d2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/dfareporting2d2-cli/README.md b/gen/dfareporting2d2-cli/README.md index e8b736fada..85754b712d 100644 --- a/gen/dfareporting2d2-cli/README.md +++ b/gen/dfareporting2d2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *dfareporting* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/dfareporting2d2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/dfareporting2d2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/dfareporting2d2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/dfareporting2d2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d2-cli). # Usage -This documentation was generated from the *dfareporting* API at revision *20160803*. The CLI is at version *0.3.6*. +This documentation was generated from the *dfareporting* API at revision *20160803*. The CLI is at version *1.0.0*. ```bash dfareporting2d2 [options] diff --git a/gen/dfareporting2d2-cli/mkdocs.yml b/gen/dfareporting2d2-cli/mkdocs.yml index 9faf582d4a..b731f316a6 100644 --- a/gen/dfareporting2d2-cli/mkdocs.yml +++ b/gen/dfareporting2d2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dfareporting v0.3.6+20160803 +site_name: dfareporting v1.0.0+20160803 site_url: http://byron.github.io/google-apis-rs/google-dfareporting2d2-cli site_description: Write integrating applications with bcore diff --git a/gen/dfareporting2d2-cli/src/main.rs b/gen/dfareporting2d2-cli/src/main.rs index 643ef7fd66..ecbb61433f 100644 --- a/gen/dfareporting2d2-cli/src/main.rs +++ b/gen/dfareporting2d2-cli/src/main.rs @@ -22334,7 +22334,7 @@ fn main() { let mut app = App::new("dfareporting2d2") .author("Sebastian Thiel ") - .version("0.3.6+20160803") + .version("1.0.0+20160803") .about("Manages your DoubleClick Campaign Manager ad campaigns and reports.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_dfareporting2d2_cli") .arg(Arg::with_name("url") diff --git a/gen/dfareporting2d3-cli/Cargo.toml b/gen/dfareporting2d3-cli/Cargo.toml index 36b7d2de75..ac03aab353 100644 --- a/gen/dfareporting2d3-cli/Cargo.toml +++ b/gen/dfareporting2d3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d3-cli" -version = "0.3.6+20160803" +version = "1.0.0+20160803" authors = ["Sebastian Thiel "] description = "A complete library to interact with dfareporting (protocol v2.3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d3-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d3/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-dfareporting2d3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d3/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dfareporting2d3] path = "../dfareporting2d3" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/dfareporting2d3-cli/README.md b/gen/dfareporting2d3-cli/README.md index 4dc31e8448..090d2cb881 100644 --- a/gen/dfareporting2d3-cli/README.md +++ b/gen/dfareporting2d3-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *dfareporting* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/dfareporting2d3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/dfareporting2d3.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/dfareporting2d3.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/dfareporting2d3.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d3-cli). # Usage -This documentation was generated from the *dfareporting* API at revision *20160803*. The CLI is at version *0.3.6*. +This documentation was generated from the *dfareporting* API at revision *20160803*. The CLI is at version *1.0.0*. ```bash dfareporting2d3 [options] diff --git a/gen/dfareporting2d3-cli/mkdocs.yml b/gen/dfareporting2d3-cli/mkdocs.yml index 3fd585ac97..985555bd8d 100644 --- a/gen/dfareporting2d3-cli/mkdocs.yml +++ b/gen/dfareporting2d3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dfareporting v0.3.6+20160803 +site_name: dfareporting v1.0.0+20160803 site_url: http://byron.github.io/google-apis-rs/google-dfareporting2d3-cli site_description: Write integrating applications with bcore diff --git a/gen/dfareporting2d3-cli/src/main.rs b/gen/dfareporting2d3-cli/src/main.rs index a1b949ddac..4071c96c9f 100644 --- a/gen/dfareporting2d3-cli/src/main.rs +++ b/gen/dfareporting2d3-cli/src/main.rs @@ -22269,7 +22269,7 @@ fn main() { let mut app = App::new("dfareporting2d3") .author("Sebastian Thiel ") - .version("0.3.6+20160803") + .version("1.0.0+20160803") .about("Manages your DoubleClick Campaign Manager ad campaigns and reports.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_dfareporting2d3_cli") .arg(Arg::with_name("url") diff --git a/gen/dfareporting2d4-cli/Cargo.toml b/gen/dfareporting2d4-cli/Cargo.toml index 78f2f349ec..e444299eef 100644 --- a/gen/dfareporting2d4-cli/Cargo.toml +++ b/gen/dfareporting2d4-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d4-cli" -version = "0.3.6+20160803" +version = "1.0.0+20160803" authors = ["Sebastian Thiel "] description = "A complete library to interact with dfareporting (protocol v2.4)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d4-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d4/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-dfareporting2d4/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d4/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dfareporting2d4] path = "../dfareporting2d4" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/dfareporting2d4-cli/README.md b/gen/dfareporting2d4-cli/README.md index 15364b53fa..963511ce88 100644 --- a/gen/dfareporting2d4-cli/README.md +++ b/gen/dfareporting2d4-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *dfareporting* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/dfareporting2d4.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/dfareporting2d4.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/dfareporting2d4.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/dfareporting2d4.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d4-cli). # Usage -This documentation was generated from the *dfareporting* API at revision *20160803*. The CLI is at version *0.3.6*. +This documentation was generated from the *dfareporting* API at revision *20160803*. The CLI is at version *1.0.0*. ```bash dfareporting2d4 [options] diff --git a/gen/dfareporting2d4-cli/mkdocs.yml b/gen/dfareporting2d4-cli/mkdocs.yml index 48142b96c0..9eec5d1559 100644 --- a/gen/dfareporting2d4-cli/mkdocs.yml +++ b/gen/dfareporting2d4-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dfareporting v0.3.6+20160803 +site_name: dfareporting v1.0.0+20160803 site_url: http://byron.github.io/google-apis-rs/google-dfareporting2d4-cli site_description: Write integrating applications with bcore diff --git a/gen/dfareporting2d4-cli/src/main.rs b/gen/dfareporting2d4-cli/src/main.rs index 8af365a627..8677929752 100644 --- a/gen/dfareporting2d4-cli/src/main.rs +++ b/gen/dfareporting2d4-cli/src/main.rs @@ -22272,7 +22272,7 @@ fn main() { let mut app = App::new("dfareporting2d4") .author("Sebastian Thiel ") - .version("0.3.6+20160803") + .version("1.0.0+20160803") .about("Manages your DoubleClick Campaign Manager ad campaigns and reports.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_dfareporting2d4_cli") .arg(Arg::with_name("url") diff --git a/gen/dfareporting2d5-cli/Cargo.toml b/gen/dfareporting2d5-cli/Cargo.toml index 4334d4fbbe..4413f31045 100644 --- a/gen/dfareporting2d5-cli/Cargo.toml +++ b/gen/dfareporting2d5-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d5-cli" -version = "0.3.6+20160803" +version = "1.0.0+20160803" authors = ["Sebastian Thiel "] description = "A complete library to interact with dfareporting (protocol v2.5)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d5-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d5/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-dfareporting2d5/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d5/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dfareporting2d5] path = "../dfareporting2d5" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/dfareporting2d5-cli/README.md b/gen/dfareporting2d5-cli/README.md index e21b78d1c4..fd8f2982ca 100644 --- a/gen/dfareporting2d5-cli/README.md +++ b/gen/dfareporting2d5-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *dfareporting* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/dfareporting2d5.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/dfareporting2d5.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/dfareporting2d5.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/dfareporting2d5.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d5-cli). # Usage -This documentation was generated from the *dfareporting* API at revision *20160803*. The CLI is at version *0.3.6*. +This documentation was generated from the *dfareporting* API at revision *20160803*. The CLI is at version *1.0.0*. ```bash dfareporting2d5 [options] diff --git a/gen/dfareporting2d5-cli/mkdocs.yml b/gen/dfareporting2d5-cli/mkdocs.yml index fe308756e0..52eecce6bb 100644 --- a/gen/dfareporting2d5-cli/mkdocs.yml +++ b/gen/dfareporting2d5-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dfareporting v0.3.6+20160803 +site_name: dfareporting v1.0.0+20160803 site_url: http://byron.github.io/google-apis-rs/google-dfareporting2d5-cli site_description: Write integrating applications with bcore diff --git a/gen/dfareporting2d5-cli/src/main.rs b/gen/dfareporting2d5-cli/src/main.rs index 58535c77b3..1b62a1a907 100644 --- a/gen/dfareporting2d5-cli/src/main.rs +++ b/gen/dfareporting2d5-cli/src/main.rs @@ -22704,7 +22704,7 @@ fn main() { let mut app = App::new("dfareporting2d5") .author("Sebastian Thiel ") - .version("0.3.6+20160803") + .version("1.0.0+20160803") .about("Manages your DoubleClick Campaign Manager ad campaigns and reports.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli") .arg(Arg::with_name("url") diff --git a/gen/dfareporting2d6-cli/Cargo.toml b/gen/dfareporting2d6-cli/Cargo.toml index 0f7be0bd87..62708f5b4b 100644 --- a/gen/dfareporting2d6-cli/Cargo.toml +++ b/gen/dfareporting2d6-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d6-cli" -version = "0.3.6+20160803" +version = "1.0.0+20160803" authors = ["Sebastian Thiel "] description = "A complete library to interact with dfareporting (protocol v2.6)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d6-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d6/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-dfareporting2d6/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d6/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dfareporting2d6] path = "../dfareporting2d6" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/dfareporting2d6-cli/README.md b/gen/dfareporting2d6-cli/README.md index b21cd21668..d84a343b52 100644 --- a/gen/dfareporting2d6-cli/README.md +++ b/gen/dfareporting2d6-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *dfareporting* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/dfareporting2d6.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/dfareporting2d6.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/dfareporting2d6.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/dfareporting2d6.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d6-cli). # Usage -This documentation was generated from the *dfareporting* API at revision *20160803*. The CLI is at version *0.3.6*. +This documentation was generated from the *dfareporting* API at revision *20160803*. The CLI is at version *1.0.0*. ```bash dfareporting2d6 [options] diff --git a/gen/dfareporting2d6-cli/mkdocs.yml b/gen/dfareporting2d6-cli/mkdocs.yml index 893f0c8c27..6fde60e762 100644 --- a/gen/dfareporting2d6-cli/mkdocs.yml +++ b/gen/dfareporting2d6-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dfareporting v0.3.6+20160803 +site_name: dfareporting v1.0.0+20160803 site_url: http://byron.github.io/google-apis-rs/google-dfareporting2d6-cli site_description: Write integrating applications with bcore diff --git a/gen/dfareporting2d6-cli/src/main.rs b/gen/dfareporting2d6-cli/src/main.rs index 743146980b..68e456ca6e 100644 --- a/gen/dfareporting2d6-cli/src/main.rs +++ b/gen/dfareporting2d6-cli/src/main.rs @@ -23403,7 +23403,7 @@ fn main() { let mut app = App::new("dfareporting2d6") .author("Sebastian Thiel ") - .version("0.3.6+20160803") + .version("1.0.0+20160803") .about("Manages your DoubleClick Campaign Manager ad campaigns and reports.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli") .arg(Arg::with_name("url") diff --git a/gen/discovery1-cli/Cargo.toml b/gen/discovery1-cli/Cargo.toml index 97ff7314c6..a784f85f1b 100644 --- a/gen/discovery1-cli/Cargo.toml +++ b/gen/discovery1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-discovery1-cli" -version = "0.3.6+00000000" +version = "1.0.0+00000000" authors = ["Sebastian Thiel "] description = "A complete library to interact with discovery (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/discovery1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-discovery1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-discovery1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-discovery1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-discovery1] path = "../discovery1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/discovery1-cli/README.md b/gen/discovery1-cli/README.md index 8720e82678..44d255114b 100644 --- a/gen/discovery1-cli/README.md +++ b/gen/discovery1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *discovery* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/discovery1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/discovery1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/discovery1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/discovery1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/discovery1-cli). # Usage -This documentation was generated from the *discovery* API at revision *00000000*. The CLI is at version *0.3.6*. +This documentation was generated from the *discovery* API at revision *00000000*. The CLI is at version *1.0.0*. ```bash discovery1 [options] diff --git a/gen/discovery1-cli/mkdocs.yml b/gen/discovery1-cli/mkdocs.yml index bbb086d363..e29b70c485 100644 --- a/gen/discovery1-cli/mkdocs.yml +++ b/gen/discovery1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: discovery v0.3.6+00000000 +site_name: discovery v1.0.0+00000000 site_url: http://byron.github.io/google-apis-rs/google-discovery1-cli site_description: Write integrating applications with bcore diff --git a/gen/discovery1-cli/src/main.rs b/gen/discovery1-cli/src/main.rs index 74283b504a..a1a596b9d1 100644 --- a/gen/discovery1-cli/src/main.rs +++ b/gen/discovery1-cli/src/main.rs @@ -302,7 +302,7 @@ fn main() { let mut app = App::new("discovery1") .author("Sebastian Thiel ") - .version("0.3.6+00000000") + .version("1.0.0+00000000") .about("Provides information about other Google APIs, such as what APIs are available, the resource, and method details for each API.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_discovery1_cli") .arg(Arg::with_name("folder") diff --git a/gen/dns1-cli/Cargo.toml b/gen/dns1-cli/Cargo.toml index 13bad9b107..f759c5d2be 100644 --- a/gen/dns1-cli/Cargo.toml +++ b/gen/dns1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dns1-cli" -version = "0.3.6+20160825" +version = "1.0.0+20160825" authors = ["Sebastian Thiel "] description = "A complete library to interact with dns (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dns1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-dns1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-dns1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dns1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dns1] path = "../dns1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/dns1-cli/README.md b/gen/dns1-cli/README.md index 70bd84c544..f3be8d0744 100644 --- a/gen/dns1-cli/README.md +++ b/gen/dns1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *dns* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/dns1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/dns1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/dns1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/dns1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dns1-cli). # Usage -This documentation was generated from the *dns* API at revision *20160825*. The CLI is at version *0.3.6*. +This documentation was generated from the *dns* API at revision *20160825*. The CLI is at version *1.0.0*. ```bash dns1 [options] diff --git a/gen/dns1-cli/mkdocs.yml b/gen/dns1-cli/mkdocs.yml index 5192002436..96d5619513 100644 --- a/gen/dns1-cli/mkdocs.yml +++ b/gen/dns1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dns v0.3.6+20160825 +site_name: dns v1.0.0+20160825 site_url: http://byron.github.io/google-apis-rs/google-dns1-cli site_description: Write integrating applications with bcore diff --git a/gen/dns1-cli/src/main.rs b/gen/dns1-cli/src/main.rs index cec07d9a69..334672c92c 100644 --- a/gen/dns1-cli/src/main.rs +++ b/gen/dns1-cli/src/main.rs @@ -1025,7 +1025,7 @@ fn main() { let mut app = App::new("dns1") .author("Sebastian Thiel ") - .version("0.3.6+20160825") + .version("1.0.0+20160825") .about("Configures and serves authoritative DNS records.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_dns1_cli") .arg(Arg::with_name("url") diff --git a/gen/doubleclickbidmanager1-cli/Cargo.toml b/gen/doubleclickbidmanager1-cli/Cargo.toml index 1a9649233b..420d7505c4 100644 --- a/gen/doubleclickbidmanager1-cli/Cargo.toml +++ b/gen/doubleclickbidmanager1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-doubleclickbidmanager1-cli" -version = "0.3.6+20160608" +version = "1.0.0+20160608" authors = ["Sebastian Thiel "] description = "A complete library to interact with DoubleClick Bid Manager (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/doubleclickbidmanager1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-doubleclickbidmanager1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-doubleclickbidmanager1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-doubleclickbidmanager1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-doubleclickbidmanager1] path = "../doubleclickbidmanager1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/doubleclickbidmanager1-cli/README.md b/gen/doubleclickbidmanager1-cli/README.md index 07b2c0db3c..4d7a2cf18d 100644 --- a/gen/doubleclickbidmanager1-cli/README.md +++ b/gen/doubleclickbidmanager1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *DoubleClick Bid Manager* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/doubleclickbidmanager1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/doubleclickbidmanager1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/doubleclickbidmanager1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/doubleclickbidmanager1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/doubleclickbidmanager1-cli). # Usage -This documentation was generated from the *DoubleClick Bid Manager* API at revision *20160608*. The CLI is at version *0.3.6*. +This documentation was generated from the *DoubleClick Bid Manager* API at revision *20160608*. The CLI is at version *1.0.0*. ```bash doubleclickbidmanager1 [options] diff --git a/gen/doubleclickbidmanager1-cli/mkdocs.yml b/gen/doubleclickbidmanager1-cli/mkdocs.yml index 5fbe34e6e0..0206d7c385 100644 --- a/gen/doubleclickbidmanager1-cli/mkdocs.yml +++ b/gen/doubleclickbidmanager1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: DoubleClick Bid Manager v0.3.6+20160608 +site_name: DoubleClick Bid Manager v1.0.0+20160608 site_url: http://byron.github.io/google-apis-rs/google-doubleclickbidmanager1-cli site_description: Write integrating applications with bcore diff --git a/gen/doubleclickbidmanager1-cli/src/main.rs b/gen/doubleclickbidmanager1-cli/src/main.rs index 8f05fedb4c..b71a5f5977 100644 --- a/gen/doubleclickbidmanager1-cli/src/main.rs +++ b/gen/doubleclickbidmanager1-cli/src/main.rs @@ -1003,7 +1003,7 @@ fn main() { let mut app = App::new("doubleclickbidmanager1") .author("Sebastian Thiel ") - .version("0.3.6+20160608") + .version("1.0.0+20160608") .about("API for viewing and managing your reports in DoubleClick Bid Manager.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_doubleclickbidmanager1_cli") .arg(Arg::with_name("folder") diff --git a/gen/doubleclicksearch2-cli/Cargo.toml b/gen/doubleclicksearch2-cli/Cargo.toml index d6ecbbc7c7..d34c87d9c8 100644 --- a/gen/doubleclicksearch2-cli/Cargo.toml +++ b/gen/doubleclicksearch2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-doubleclicksearch2-cli" -version = "0.3.6+20160831" +version = "1.0.0+20160831" authors = ["Sebastian Thiel "] description = "A complete library to interact with doubleclicksearch (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/doubleclicksearch2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-doubleclicksearch2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-doubleclicksearch2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-doubleclicksearch2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-doubleclicksearch2] path = "../doubleclicksearch2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/doubleclicksearch2-cli/README.md b/gen/doubleclicksearch2-cli/README.md index 6d9e9ccedc..28ab19282f 100644 --- a/gen/doubleclicksearch2-cli/README.md +++ b/gen/doubleclicksearch2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *doubleclicksearch* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/doubleclicksearch2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/doubleclicksearch2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/doubleclicksearch2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/doubleclicksearch2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/doubleclicksearch2-cli). # Usage -This documentation was generated from the *doubleclicksearch* API at revision *20160831*. The CLI is at version *0.3.6*. +This documentation was generated from the *doubleclicksearch* API at revision *20160831*. The CLI is at version *1.0.0*. ```bash doubleclicksearch2 [options] diff --git a/gen/doubleclicksearch2-cli/mkdocs.yml b/gen/doubleclicksearch2-cli/mkdocs.yml index 99fbb37c0d..2caf467b94 100644 --- a/gen/doubleclicksearch2-cli/mkdocs.yml +++ b/gen/doubleclicksearch2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: doubleclicksearch v0.3.6+20160831 +site_name: doubleclicksearch v1.0.0+20160831 site_url: http://byron.github.io/google-apis-rs/google-doubleclicksearch2-cli site_description: Write integrating applications with bcore diff --git a/gen/doubleclicksearch2-cli/src/main.rs b/gen/doubleclicksearch2-cli/src/main.rs index c4f411eef6..d22bef9fcd 100644 --- a/gen/doubleclicksearch2-cli/src/main.rs +++ b/gen/doubleclicksearch2-cli/src/main.rs @@ -1291,7 +1291,7 @@ fn main() { let mut app = App::new("doubleclicksearch2") .author("Sebastian Thiel ") - .version("0.3.6+20160831") + .version("1.0.0+20160831") .about("Reports and modifies your advertising data in DoubleClick Search (for example, campaigns, ad groups, keywords, and conversions).") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_doubleclicksearch2_cli") .arg(Arg::with_name("url") diff --git a/gen/drive2-cli/Cargo.toml b/gen/drive2-cli/Cargo.toml index a51018c436..781e9d8bb7 100644 --- a/gen/drive2-cli/Cargo.toml +++ b/gen/drive2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-drive2-cli" -version = "0.3.6+20160901" +version = "1.0.0+20160901" authors = ["Sebastian Thiel "] description = "A complete library to interact with drive (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/drive2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-drive2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-drive2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-drive2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-drive2] path = "../drive2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/drive2-cli/README.md b/gen/drive2-cli/README.md index ceb2a0929e..597cb5c2d1 100644 --- a/gen/drive2-cli/README.md +++ b/gen/drive2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *drive* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/drive2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/drive2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/drive2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/drive2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/drive2-cli). # Usage -This documentation was generated from the *drive* API at revision *20160901*. The CLI is at version *0.3.6*. +This documentation was generated from the *drive* API at revision *20160901*. The CLI is at version *1.0.0*. ```bash drive2 [options] diff --git a/gen/drive2-cli/mkdocs.yml b/gen/drive2-cli/mkdocs.yml index f2ebfc1e89..89cc299841 100644 --- a/gen/drive2-cli/mkdocs.yml +++ b/gen/drive2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: drive v0.3.6+20160901 +site_name: drive v1.0.0+20160901 site_url: http://byron.github.io/google-apis-rs/google-drive2-cli site_description: Write integrating applications with bcore diff --git a/gen/drive2-cli/src/main.rs b/gen/drive2-cli/src/main.rs index 849369fe66..165c121def 100644 --- a/gen/drive2-cli/src/main.rs +++ b/gen/drive2-cli/src/main.rs @@ -6894,7 +6894,7 @@ fn main() { let mut app = App::new("drive2") .author("Sebastian Thiel ") - .version("0.3.6+20160901") + .version("1.0.0+20160901") .about("Manages files in Drive including uploading, downloading, searching, detecting changes, and updating sharing permissions.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_drive2_cli") .arg(Arg::with_name("url") diff --git a/gen/drive3-cli/Cargo.toml b/gen/drive3-cli/Cargo.toml index a68dc193a7..333b8345b9 100644 --- a/gen/drive3-cli/Cargo.toml +++ b/gen/drive3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-drive3-cli" -version = "0.3.6+20160901" +version = "1.0.0+20160901" authors = ["Sebastian Thiel "] description = "A complete library to interact with drive (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/drive3-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-drive3/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-drive3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-drive3/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-drive3] path = "../drive3" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/drive3-cli/README.md b/gen/drive3-cli/README.md index 46ad7f3a34..d85daa18ad 100644 --- a/gen/drive3-cli/README.md +++ b/gen/drive3-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *drive* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/drive3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/drive3.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/drive3.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/drive3.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/drive3-cli). # Usage -This documentation was generated from the *drive* API at revision *20160901*. The CLI is at version *0.3.6*. +This documentation was generated from the *drive* API at revision *20160901*. The CLI is at version *1.0.0*. ```bash drive3 [options] diff --git a/gen/drive3-cli/mkdocs.yml b/gen/drive3-cli/mkdocs.yml index d3e7d17602..48e38aa999 100644 --- a/gen/drive3-cli/mkdocs.yml +++ b/gen/drive3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: drive v0.3.6+20160901 +site_name: drive v1.0.0+20160901 site_url: http://byron.github.io/google-apis-rs/google-drive3-cli site_description: Write integrating applications with bcore diff --git a/gen/drive3-cli/src/main.rs b/gen/drive3-cli/src/main.rs index 43ca4bca8b..fea6fa7fc6 100644 --- a/gen/drive3-cli/src/main.rs +++ b/gen/drive3-cli/src/main.rs @@ -3883,7 +3883,7 @@ fn main() { let mut app = App::new("drive3") .author("Sebastian Thiel ") - .version("0.3.6+20160901") + .version("1.0.0+20160901") .about("Manages files in Drive including uploading, downloading, searching, detecting changes, and updating sharing permissions.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_drive3_cli") .arg(Arg::with_name("url") diff --git a/gen/fitness1-cli/Cargo.toml b/gen/fitness1-cli/Cargo.toml index 5d3a8908ea..b19257e412 100644 --- a/gen/fitness1-cli/Cargo.toml +++ b/gen/fitness1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-fitness1-cli" -version = "0.3.6+20160801" +version = "1.0.0+20160801" authors = ["Sebastian Thiel "] description = "A complete library to interact with fitness (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/fitness1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-fitness1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-fitness1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-fitness1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-fitness1] path = "../fitness1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/fitness1-cli/README.md b/gen/fitness1-cli/README.md index 139060c144..aeca2c9933 100644 --- a/gen/fitness1-cli/README.md +++ b/gen/fitness1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *fitness* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/fitness1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/fitness1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/fitness1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/fitness1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/fitness1-cli). # Usage -This documentation was generated from the *fitness* API at revision *20160801*. The CLI is at version *0.3.6*. +This documentation was generated from the *fitness* API at revision *20160801*. The CLI is at version *1.0.0*. ```bash fitness1 [options] diff --git a/gen/fitness1-cli/mkdocs.yml b/gen/fitness1-cli/mkdocs.yml index ed4d603ed9..cc08dcc47d 100644 --- a/gen/fitness1-cli/mkdocs.yml +++ b/gen/fitness1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: fitness v0.3.6+20160801 +site_name: fitness v1.0.0+20160801 site_url: http://byron.github.io/google-apis-rs/google-fitness1-cli site_description: Write integrating applications with bcore diff --git a/gen/fitness1-cli/src/main.rs b/gen/fitness1-cli/src/main.rs index 87739193bb..d66926e6f3 100644 --- a/gen/fitness1-cli/src/main.rs +++ b/gen/fitness1-cli/src/main.rs @@ -1540,7 +1540,7 @@ fn main() { let mut app = App::new("fitness1") .author("Sebastian Thiel ") - .version("0.3.6+20160801") + .version("1.0.0+20160801") .about("Stores and accesses user data in the fitness store from apps on any platform.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_fitness1_cli") .arg(Arg::with_name("url") diff --git a/gen/freebase1-cli/Cargo.toml b/gen/freebase1-cli/Cargo.toml deleted file mode 100644 index f7ea7b38e2..0000000000 --- a/gen/freebase1-cli/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-freebase1-cli" -version = "0.3.6+20150728" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with freebase (protocol v1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/freebase1-cli" -homepage = "https://developers.google.com/freebase/" -documentation = "http://byron.github.io/google-apis-rs/google_freebase1_cli" -license = "MIT" -keywords = ["freebase", "google", "cli"] - -[[bin]] -name = "freebase1" - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -strsim = "^0.4" -yup-hyper-mock = "^1.0" -clap = "^2.0" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-freebase1/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-freebase1/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - - -[dependencies.google-freebase1] -path = "../freebase1" -optional = true -default-features = false diff --git a/gen/freebase1-cli/LICENSE.md b/gen/freebase1-cli/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/freebase1-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/freebase1-cli/README.md b/gen/freebase1-cli/README.md deleted file mode 100644 index 4c79a05974..0000000000 --- a/gen/freebase1-cli/README.md +++ /dev/null @@ -1,110 +0,0 @@ - -The `freebase1` command-line interface *(CLI)* allows to use most features of the *Google freebase* service from the comfort of your terminal. - -By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's -capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. - -If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. - -Everything else about the *freebase* API can be found at the -[official documentation site](https://developers.google.com/freebase/). - -# Downloads - -You can download the pre-compiled 64bit binaries for the following platforms: - -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/freebase1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/freebase1.tar.gz) - -Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/freebase1-cli). - -# Usage - -This documentation was generated from the *freebase* API at revision *20150728*. The CLI is at version *0.3.6*. - -```bash -freebase1 [options] - methods - reconcile [-p ]... [-o ] - search [-p ]... [-o ] - freebase1 --help - -Configuration: - --config-dir - A directory into which we will store our persistent data. Defaults to - a user-writable directory that we will create during the first invocation. - [default: ~/.google-service-cli] - --debug - Output all server communication to standard error. `tx` and `rx` are placed - into the same stream. - --debug-auth - Output all communication related to authentication to standard error. `tx` - and `rx` are placed into the same stream. - -``` - -# Configuration - -The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `freebase1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. - -More information about the various kinds of persistent data are given in the following paragraphs. - -# Authentication - -Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the -set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. - -If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a -method that is read-only, it will ask only for a read-only scope. -You may use the `--scope` flag to specify a scope directly. -All applicable scopes are documented in the respective method's CLI documentation. - -The first time a scope is used, the user is asked for permission. Follow the instructions given -by the CLI to grant permissions, or to decline. - -If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration -directory, e.g. `~/.google-service-cli/freebase1-token-.json`. No manual management of these tokens -is necessary. - -To revoke granted authentication, please refer to the [official documentation][revoke-access]. - -# Application Secrets - -In order to allow any application to use Google services, it will need to be registered using the -[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it -one by one. Most APIs can be used for free and have a daily quota. - -To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI -comes with a default application secret that is configured accordingly. This also means that heavy usage -all around the world may deplete the daily quota. - -You can workaround this limitation by putting your own secrets file at this location: -`~/.google-service-cli/freebase1-secret.json`, assuming that the required *freebase* API -was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at -*APIs & auth -> Credentials -> Download JSON* and used as is. - -Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. - - -# Debugging - -Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know -what exactly led to a particular issue. This is done by allowing all client-server communication to be -output to standard error *as-is*. - -The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag -will cause all communication related to authentication to standard error. -If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the -issue at hand. - -You may consider redirecting standard error into a file for ease of use, e.g. `freebase1 --debug [options] 2>debug.txt`. - - -[scopes]: https://developers.google.com/+/api/oauth#scopes -[revoke-access]: http://webapps.stackexchange.com/a/30849 -[google-dev-console]: https://console.developers.google.com/ -[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/freebase1-cli/mkdocs.yml b/gen/freebase1-cli/mkdocs.yml deleted file mode 100644 index 00414730c5..0000000000 --- a/gen/freebase1-cli/mkdocs.yml +++ /dev/null @@ -1,18 +0,0 @@ -site_name: freebase v0.3.6+20150728 -site_url: http://byron.github.io/google-apis-rs/google-freebase1-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/freebase1-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['methods_reconcile.md', 'Methods', 'Reconcile'] -- ['methods_search.md', 'Methods', 'Search'] - -theme: readthedocs - -copyright: Copyright © 2015-2016, `Sebastian Thiel` - diff --git a/gen/freebase1-cli/src/cmn.rs b/gen/freebase1-cli/src/cmn.rs deleted file mode 100644 index 779c1dc086..0000000000 --- a/gen/freebase1-cli/src/cmn.rs +++ /dev/null @@ -1,721 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use serde_json as json; -use serde_json::value::Value; -use mime::Mime; -use clap::{App, SubCommand}; -use strsim; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - - -pub enum ComplexType { - Pod, - Vec, - Map, -} - - // Null, - // Bool(bool), - // I64(i64), - // U64(u64), - // F64(f64), - // String(String), - -pub enum JsonType { - Boolean, - Int, - Uint, - Float, - String, -} - -pub struct JsonTypeInfo { - pub jtype: JsonType, - pub ctype: ComplexType, -} - -// Based on @erickt user comment. Thanks for the idea ! -// Remove all keys whose values are null from given value (changed in place) -pub fn remove_json_null_values(value: &mut Value) { - match *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); - } - } - _ => {} - } -} - -fn did_you_mean<'a>(v: &str, possible_values: &[&'a str]) -> Option<&'a str> { - - let mut candidate: Option<(f64, &str)> = None; - for pv in possible_values { - let confidence = strsim::jaro_winkler(v, pv); - if confidence > 0.8 && (candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence)) { - candidate = Some((confidence, pv)); - } - } - match candidate { - None => None, - Some((_, candidate)) => Some(candidate), - } -} - -pub enum CallType { - Upload(UploadProtocol), - Standard, -} - -arg_enum!{ - pub enum UploadProtocol { - Simple, - Resumable - } -} - -impl AsRef for UploadProtocol { - fn as_ref(&self) -> &str { - match *self { - UploadProtocol::Simple => "simple", - UploadProtocol::Resumable => "resumable" - } - } -} - -impl AsRef for CallType { - fn as_ref(&self) -> &str { - match *self { - CallType::Upload(ref proto) => proto.as_ref(), - CallType::Standard => "standard-request" - } - } -} - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.join(".") - } -} - -impl From<&'static str> for FieldCursor { - fn from(value: &'static str) -> FieldCursor { - let mut res = FieldCursor::default(); - res.set(value).unwrap(); - res - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn did_you_mean(value: &str, possible_values: &[&str]) -> Option { - if value.len() == 0 { - return None - } - - let mut last_c = FIELD_SEP; - - let mut field = String::new(); - let mut output = String::new(); - - let push_field = |fs: &mut String, f: &mut String| { - if f.len() > 0 { - fs.push_str( - match did_you_mean(&f, possible_values) { - Some(candidate) => candidate, - None => &f, - }); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - if c == FIELD_SEP { - if last_c != FIELD_SEP { - push_field(&mut output, &mut field); - } - output.push(c); - } else { - field.push(c); - } - - last_c = c; - } - - push_field(&mut output, &mut field); - - if &output == value { - None - } else { - Some(output) - } - } - - pub fn set_json_value(&self, mut object: &mut Value, - value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, - orig_cursor: &FieldCursor) { - assert!(self.0.len() > 0); - - for field in &self.0[..self.0.len()-1] { - let tmp = object; - object = - match *tmp { - Value::Object(ref mut mapping) => { - mapping.entry(field.to_owned()).or_insert( - Value::Object(Default::default()) - ) - }, - _ => panic!("We don't expect non-object Values here ...") - }; - } - - match *object { - Value::Object(ref mut mapping) => { - let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| - -> Value { - match jtype { - JsonType::Boolean => - Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => - Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => - Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => - Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => - Value::String(value.to_owned()), - } - }; - - match type_info.ctype { - ComplexType::Pod => { - if mapping.insert(field.to_owned(), to_jval(value, type_info.jtype, err)).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - }, - ComplexType::Vec => { - match *mapping.entry(field.to_owned()) - .or_insert(Value::Array(Default::default())) { - Value::Array(ref mut values) => values.push(to_jval(value, type_info.jtype, err)), - _ => unreachable!() - } - }, - ComplexType::Map => { - let (key, value) = parse_kv_arg(value, err, true); - let jval = to_jval(value.unwrap_or(""), type_info.jtype, err); - - match *mapping.entry(field.to_owned()) - .or_insert(Value::Object(Default::default())) { - Value::Object(ref mut value_map) => { - if value_map.insert(key.to_owned(), jval).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - } - _ => unreachable!() - } - } - } - }, - _ => unreachable!() - } - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); - match kv.find('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, Some("")) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut InvalidOptionsError) -> CallType { - CallType::Upload( - match UploadProtocol::from_str(name) { - Ok(up) => up, - Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); - UploadProtocol::Simple - } - }) -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::Io((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { - let f = arg.unwrap_or("-"); - match f { - "-" => Ok(Box::new(stdout())), - _ => match fs::OpenOptions::new().create(true).write(true).open(f) { - Ok(f) => Ok(Box::new(f)), - Err(io_err) => Err(io_err), - } - } -} - - -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, - arg_type: &'a str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError(arg_name.to_owned(), arg_type.to_owned(), arg.to_string(), format!("{}", perr)) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - type Error = json::Error; - - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Result<(), json::Error> { - match token { - None => { - match fs::remove_file(self.path(scope_hash)) { - Err(err) => - match err.kind() { - io::ErrorKind::NotFound => Ok(()), - _ => Err(json::Error::Io(err)) - }, - Ok(_) => Ok(()), - } - } - Some(token) => { - match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { - Ok(mut f) => { - match json::to_writer_pretty(&mut f, &token) { - Ok(_) => Ok(()), - Err(serde_err) => Err(serde_err), - } - }, - Err(io_err) => Err(json::Error::Io(io_err)) - } - } - } - } - - fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, json::Error> { - match fs::File::open(&self.path(scope_hash)) { - Ok(f) => { - match json::de::from_reader(f) { - Ok(token) => Ok(Some(token)), - Err(err) => Err(err), - } - }, - Err(io_err) => { - match io_err.kind() { - io::ErrorKind::NotFound => Ok(None), - _ => Err(json::Error::Io(io_err)) - } - } - } - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::Error)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - Io((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty."), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::Io((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}.", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - Io((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::Io((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}.", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type.", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String, Option, Option), - Duplicate(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor.", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character.", field), - FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = - match *suggestion { - Some(ref s) => { - let kv = - match *value { - Some(ref v) => format!("{}={}", s, v), - None => s.clone(), - }; - format!(" Did you mean '{}' ?", kv) - }, - None => String::new(), - }; - writeln!(f, "Field '{}' does not exist.{}", field, suffix) - }, - FieldError::Duplicate(ref cursor) - => writeln!(f, "Value at '{}' was already set", cursor), - FieldError::Empty - => writeln!(f, "Field names must not be empty."), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError(String, String, String, String), - UnknownParameter(String, Vec<&'static str>), - InvalidUploadProtocol(String, Vec), - InvalidKeyValueSyntax(String, bool), - Input(InputError), - Field(FieldError), - MissingCommandError, - MissingMethodError(String), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let suffix = - match did_you_mean(param_name, &possible_values) { - Some(v) => format!(" Did you mean '{}' ?", v), - None => String::new(), - }; - write!(f, "Parameter '{}' is unknown.{}\n", param_name, suffix) - }, - CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { - let hashmap_info = if is_hashmap { "hashmap " } else { "" }; - writeln!(f, "'{}' does not match {}pattern =.", kv, hashmap_info) - }, - CLIError::MissingCommandError => writeln!(f, "Please specify the main sub-command."), - CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the '{}' command.", cmd), - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, - json_console_secret: &str) - -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::Io( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret - = json::from_str(json_console_secret).unwrap(); - match json::to_writer_pretty(&mut f, &console_secret) { - Err(serde_err) => match serde_err { - json::Error::Io(err) => err, - _ => panic!("Unexpected serde error: {:#?}", serde_err) - }, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(f) => { - match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::Io(err)) => - return secret_io_error(err), - Err(json_err) => - return Err(CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::DecoderError( - (secret_str(), json_err) - )))), - Ok(console_secret) => - match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} diff --git a/gen/freebase1-cli/src/main.rs b/gen/freebase1-cli/src/main.rs deleted file mode 100644 index f0e5a86e05..0000000000 --- a/gen/freebase1-cli/src/main.rs +++ /dev/null @@ -1,468 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -#[macro_use] -extern crate clap; -extern crate yup_oauth2 as oauth2; -extern crate yup_hyper_mock as mock; -extern crate serde; -extern crate serde_json; -extern crate hyper; -extern crate mime; -extern crate strsim; -extern crate google_freebase1 as api; - -use std::env; -use std::io::{self, Write}; -use clap::{App, SubCommand, Arg}; - -mod cmn; - -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol, - calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, FlowType}; -use serde_json as json; -use clap::ArgMatches; - -enum DoitError { - IoError(String, io::Error), - ApiError(api::Error), -} - -struct Engine<'n> { - opt: ArgMatches<'n>, - hub: api::Freebase>, - gp: Vec<&'static str>, - gpm: Vec<(&'static str, &'static str)>, -} - - -impl<'n> Engine<'n> { - fn _methods_reconcile(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.methods().reconcile(); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "prop" => { - call = call.add_prop(value.unwrap_or("")); - }, - "name" => { - call = call.name(value.unwrap_or("")); - }, - "limit" => { - call = call.limit(arg_from_str(value.unwrap_or("-0"), err, "limit", "integer")); - }, - "lang" => { - call = call.add_lang(value.unwrap_or("")); - }, - "kind" => { - call = call.add_kind(value.unwrap_or("")); - }, - "confidence" => { - call = call.confidence(arg_from_str(value.unwrap_or("0.0"), err, "confidence", "number")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["lang", "kind", "name", "confidence", "prop", "limit"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _methods_search(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut download_mode = false; - let mut call = self.hub.methods().search(); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "without" => { - call = call.add_without(value.unwrap_or("")); - }, - "with" => { - call = call.add_with(value.unwrap_or("")); - }, - "type" => { - call = call.add_type(value.unwrap_or("")); - }, - "stemmed" => { - call = call.stemmed(arg_from_str(value.unwrap_or("false"), err, "stemmed", "boolean")); - }, - "spell" => { - call = call.spell(value.unwrap_or("")); - }, - "scoring" => { - call = call.scoring(value.unwrap_or("")); - }, - "query" => { - call = call.query(value.unwrap_or("")); - }, - "prefixed" => { - call = call.prefixed(arg_from_str(value.unwrap_or("false"), err, "prefixed", "boolean")); - }, - "output" => { - call = call.output(value.unwrap_or("")); - }, - "mql-output" => { - call = call.mql_output(value.unwrap_or("")); - }, - "mid" => { - call = call.add_mid(value.unwrap_or("")); - }, - "limit" => { - call = call.limit(arg_from_str(value.unwrap_or("-0"), err, "limit", "integer")); - }, - "lang" => { - call = call.add_lang(value.unwrap_or("")); - }, - "indent" => { - call = call.indent(arg_from_str(value.unwrap_or("false"), err, "indent", "boolean")); - }, - "help" => { - call = call.help(value.unwrap_or("")); - }, - "format" => { - call = call.format(value.unwrap_or("")); - }, - "filter" => { - call = call.add_filter(value.unwrap_or("")); - }, - "exact" => { - call = call.exact(arg_from_str(value.unwrap_or("false"), err, "exact", "boolean")); - }, - "encode" => { - call = call.encode(value.unwrap_or("")); - }, - "domain" => { - call = call.add_domain(value.unwrap_or("")); - }, - "cursor" => { - call = call.cursor(arg_from_str(value.unwrap_or("-0"), err, "cursor", "integer")); - }, - "callback" => { - call = call.callback(value.unwrap_or("")); - }, - "as-of-time" => { - call = call.as_of_time(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - if key == "alt" && value.unwrap_or("unset") == "media" { - download_mode = true; - } - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["domain", "help", "query", "stemmed", "cursor", "prefixed", "exact", "mid", "encode", "type", "as-of-time", "scoring", "format", "spell", "with", "lang", "indent", "filter", "callback", "without", "limit", "output", "mql-output"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok(mut response) => { - if !download_mode { - } else { - io::copy(&mut response, &mut ostream).unwrap(); - ostream.flush().unwrap(); - } - Ok(()) - } - } - } - } - - fn _doit(&self, dry_run: bool) -> Result, Option> { - let mut err = InvalidOptionsError::new(); - let mut call_result: Result<(), DoitError> = Ok(()); - let mut err_opt: Option = None; - match self.opt.subcommand() { - ("methods", Some(opt)) => { - match opt.subcommand() { - ("reconcile", Some(opt)) => { - call_result = self._methods_reconcile(opt, dry_run, &mut err); - }, - ("search", Some(opt)) => { - call_result = self._methods_search(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("methods".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - _ => { - err.issues.push(CLIError::MissingCommandError); - writeln!(io::stderr(), "{}\n", self.opt.usage()).ok(); - } - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - Err(err_opt) - } else { - Ok(call_result) - } - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: ArgMatches<'n>) -> Result, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "freebase1-secret.json", - "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, - if opt.is_present("debug-auth") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }, - JsonTokenStorage { - program_name: "freebase1", - db_dir: config_dir.clone(), - }, Some(FlowType::InstalledRedirect(54324))); - - let client = - if opt.is_present("debug") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }; - let engine = Engine { - opt: opt, - hub: api::Freebase::new(client, auth), - gp: vec!["alt", "fields", "key", "oauth-token", "pretty-print", "quota-user", "user-ip"], - gpm: vec![ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ] - }; - - match engine._doit(true) { - Err(Some(err)) => Err(err), - Err(None) => Ok(engine), - Ok(_) => unreachable!(), - } - } - - fn doit(&self) -> Result<(), DoitError> { - match self._doit(false) { - Ok(res) => res, - Err(_) => unreachable!(), - } - } -} - -fn main() { - let mut exit_status = 0i32; - let arg_data = [ - ("methods", "methods: 'reconcile' and 'search'", vec![ - ("reconcile", - Some(r##"Reconcile entities to Freebase open data."##), - "Details at http://byron.github.io/google-apis-rs/google_freebase1_cli/methods_reconcile", - vec![ - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("search", - Some(r##"Search Freebase open data."##), - "Details at http://byron.github.io/google-apis-rs/google_freebase1_cli/methods_search", - vec![ - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ]; - - let mut app = App::new("freebase1") - .author("Sebastian Thiel ") - .version("0.3.6+20150728") - .about("Find Freebase entities using textual queries and other constraints.") - .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_freebase1_cli") - .arg(Arg::with_name("folder") - .long("config-dir") - .help("A directory into which we will store our persistent data. Defaults to a user-writable directory that we will create during the first invocation.[default: ~/.google-service-cli") - .multiple(false) - .takes_value(true)) - .arg(Arg::with_name("debug") - .long("debug") - .help("Output all server communication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)) - .arg(Arg::with_name("debug-auth") - .long("debug-auth") - .help("Output all communication related to authentication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)); - - for &(main_command_name, about, ref subcommands) in arg_data.iter() { - let mut mcmd = SubCommand::with_name(main_command_name).about(about); - - for &(sub_command_name, ref desc, url_info, ref args) in subcommands { - let mut scmd = SubCommand::with_name(sub_command_name); - if let &Some(desc) = desc { - scmd = scmd.about(desc); - } - scmd = scmd.after_help(url_info); - - for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args { - let arg_name_str = - match (arg_name, flag) { - (&Some(an), _ ) => an, - (_ , &Some(f)) => f, - _ => unreachable!(), - }; - let mut arg = Arg::with_name(arg_name_str) - .empty_values(false); - if let &Some(short_flag) = flag { - arg = arg.short(short_flag); - } - if let &Some(desc) = desc { - arg = arg.help(desc); - } - if arg_name.is_some() && flag.is_some() { - arg = arg.takes_value(true); - } - if let &Some(required) = required { - arg = arg.required(required); - } - if let &Some(multi) = multi { - arg = arg.multiple(multi); - } - scmd = scmd.arg(arg); - } - mcmd = mcmd.subcommand(scmd); - } - app = app.subcommand(mcmd); - } - - let matches = app.get_matches(); - - let debug = matches.is_present("debug"); - match Engine::new(matches) { - Err(err) => { - exit_status = err.exit_code; - writeln!(io::stderr(), "{}", err).ok(); - }, - Ok(engine) => { - if let Err(doit_err) = engine.doit() { - exit_status = 1; - match doit_err { - DoitError::IoError(path, err) => { - writeln!(io::stderr(), "Failed to open output file '{}': {}", path, err).ok(); - }, - DoitError::ApiError(err) => { - if debug { - writeln!(io::stderr(), "{:#?}", err).ok(); - } else { - writeln!(io::stderr(), "{}", err).ok(); - } - } - } - } - } - } - - std::process::exit(exit_status); -} \ No newline at end of file diff --git a/gen/freebase1/Cargo.toml b/gen/freebase1/Cargo.toml deleted file mode 100644 index 726becb8f4..0000000000 --- a/gen/freebase1/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-freebase1" -version = "0.1.14+20150728" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with freebase (protocol v1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/freebase1" -homepage = "https://developers.google.com/freebase/" -documentation = "http://byron.github.io/google-apis-rs/google_freebase1" -license = "MIT" -keywords = ["freebase", "google", "protocol", "web", "api"] -build = "src/build.rs" - - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -url = "= 0.5" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - diff --git a/gen/freebase1/LICENSE.md b/gen/freebase1/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/freebase1/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/freebase1/README.md b/gen/freebase1/README.md deleted file mode 100644 index 5f39ac039f..0000000000 --- a/gen/freebase1/README.md +++ /dev/null @@ -1,183 +0,0 @@ - -The `google-freebase1` library allows access to all features of the *Google freebase* service. - -This documentation was generated from *freebase* crate version *0.1.14+20150728*, where *20150728* is the exact revision of the *freebase:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. - -Everything else about the *freebase* *v1* API can be found at the -[official documentation site](https://developers.google.com/freebase/). -# Features - -Use the following functionality with ease from the central [hub](http://byron.github.io/google-apis-rs/google_freebase1/struct.Freebase.html) ... - - -* [reconcile](http://byron.github.io/google-apis-rs/google_freebase1/struct.MethodReconcileCall.html) -* [search](http://byron.github.io/google-apis-rs/google_freebase1/struct.MethodSearchCall.html) - -Download supported by ... - -* [*search*](http://byron.github.io/google-apis-rs/google_freebase1/struct.MethodSearchCall.html) - - - -# Structure of this Library - -The API is structured into the following primary items: - -* **[Hub](http://byron.github.io/google-apis-rs/google_freebase1/struct.Freebase.html)** - * a central object to maintain state and allow accessing all *Activities* - * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_freebase1/trait.MethodsBuilder.html) which in turn - allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_freebase1/trait.CallBuilder.html) -* **[Resources](http://byron.github.io/google-apis-rs/google_freebase1/trait.Resource.html)** - * primary types that you can apply *Activities* to - * a collection of properties and *Parts* - * **[Parts](http://byron.github.io/google-apis-rs/google_freebase1/trait.Part.html)** - * a collection of properties - * never directly used in *Activities* -* **[Activities](http://byron.github.io/google-apis-rs/google_freebase1/trait.CallBuilder.html)** - * 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() -``` - -Or specifically ... - -```ignore -let r = hub.methods().reconcile(...).doit() -``` - -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-freebase1 = "*" -``` - -## A complete example - -```Rust -extern crate hyper; -extern crate yup_oauth2 as oauth2; -extern crate google_freebase1 as freebase1; -use freebase1::{Result, Error}; -use std::default::Default; -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use freebase1::Freebase; - -// Get an ApplicationSecret instance by some means. It contains the `client_id` and -// `client_secret`, among other things. -let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - ::default(), None); -let mut hub = Freebase::new(hyper::Client::new(), auth); -// 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.methods().reconcile() - .add_prop("eirmod") - .name("sit") - .limit(-65) - .add_lang("sed") - .add_kind("et") - .confidence(0.824373746908) - .doit(); - -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::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](http://byron.github.io/google-apis-rs/google_freebase1/enum.Result.html) enumeration as return value of -the doit() methods, or handed as possibly intermediate results to either the -[Hub Delegate](http://byron.github.io/google-apis-rs/google_freebase1/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_freebase1/../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](http://byron.github.io/google-apis-rs/google_freebase1/enum.Result.html), should be -read by you to obtain the media. -If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_freebase1/trait.ResponseResult.html), 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](http://byron.github.io/google-apis-rs/google_freebase1/trait.Delegate.html) to the -[Method Builder](http://byron.github.io/google-apis-rs/google_freebase1/trait.CallBuilder.html) 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](http://byron.github.io/google-apis-rs/google_freebase1/trait.Delegate.html) 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 [enocodable](http://byron.github.io/google-apis-rs/google_freebase1/trait.RequestValue.html) and -[decodable](http://byron.github.io/google-apis-rs/google_freebase1/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -are valid. -Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_freebase1/trait.Part.html) 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](http://byron.github.io/google-apis-rs/google_freebase1/trait.CallBuilder.html), 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](http://byron.github.io/google-apis-rs/google_freebase1/trait.RequestValue.html) 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 **freebase1** 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-rs/LICENSE.md diff --git a/gen/freebase1/src/build.rs b/gen/freebase1/src/build.rs deleted file mode 100644 index 0bebaf0bf0..0000000000 --- a/gen/freebase1/src/build.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[cfg(feature = "with-serde-codegen")] -mod inner { - extern crate serde_codegen; - - use std::env; - use std::path::Path; - - pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - - let src = Path::new("src/lib.rs.in"); - let dst = Path::new(&out_dir).join("lib.rs"); - - serde_codegen::expand(&src, &dst).unwrap(); - } -} - -#[cfg(not(feature = "with-serde-codegen"))] -mod inner { - pub fn main() {} -} - -pub fn main() { - inner::main() -} \ No newline at end of file diff --git a/gen/freebase1/src/cmn.rs b/gen/freebase1/src/cmn.rs deleted file mode 100644 index d75063e466..0000000000 --- a/gen/freebase1/src/cmn.rs +++ /dev/null @@ -1,753 +0,0 @@ -// COPY OF 'src/rust/api/cmn.rs' -// DO NOT EDIT -use std::io::{self, Read, Seek, Cursor, Write, SeekFrom}; -use std; -use std::fmt::{self, Display}; -use std::str::FromStr; -use std::error; -use std::thread::sleep; -use std::time::Duration; - -use mime::{Mime, TopLevel, SubLevel, Attr, Value}; -use oauth2::{TokenType, Retry, self}; -use hyper; -use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header, - HeaderFormat, Bearer}; -use hyper::http::h1::LINE_ENDING; -use hyper::method::Method; -use hyper::status::StatusCode; - -use serde_json as json; - -/// 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 {} -impl 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 utility type which can decode a server response that indicates error -#[derive(Deserialize)] -pub struct JsonServerError { - pub error: String, - pub error_description: Option -} - -/// A utility to represent detailed errors we might see in case there are BadRequests. -/// The latter happen if the sent parameters or request structures are unsound -#[derive(Deserialize, Serialize, Debug)] -pub struct ErrorResponse { - error: ServerError, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerError { - errors: Vec, - code: u16, - message: String, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerMessage { - domain: String, - reason: String, - message: String, - #[serde(rename="locationType")] - location_type: Option, - location: Option -} - -#[derive(Copy, Clone)] -pub struct DummyNetworkStream; - -impl Read for DummyNetworkStream { - fn read(&mut self, _: &mut [u8]) -> io::Result { - Ok(0) - } -} - -impl Write for DummyNetworkStream { - fn write(&mut self, _: &[u8]) -> io::Result { - Ok(0) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl hyper::net::NetworkStream for DummyNetworkStream { - fn peer_addr(&mut self) -> io::Result { - Ok("127.0.0.1:1337".parse().unwrap()) - } - - fn set_read_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } - - fn set_write_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } -} - - -/// 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 { - - /// 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, MethodInfo) {} - - /// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), 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, &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 { - 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: &error::Error) -> Option { - 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 { - 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::client::Response, Option, _: Option) -> 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(ErrorResponse), - - /// 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(Box), - - /// 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::client::Response), -} - - -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - 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 err) => { - try!(writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message)); - for err in err.error.errors.iter() { - try!(writeln!(f, " {}: {}, {}{}", - err.domain, - err.message, - err.reason, - match &err.location { - &Some(ref loc) => format!("@{}", loc), - &None => String::new(), - })); - } - 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 description(&self) -> &str { - match *self { - Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(_, ref err) => err.description(), - _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" - } - } - - fn cause(&self) -> Option<&error::Error> { - match *self { - Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(_, ref err) => err.cause(), - _ => None - } - } -} - -/// A universal result type used as return for all calls. -pub type Result = std::result::Result; - -/// Contains information about an API request. -pub struct MethodInfo { - pub id: &'static str, - pub http_method: Method, -} - -const BOUNDARY: &'static 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<(Headers, &'a mut Read)>, - current_part: Option<(Cursor>, &'a mut Read)>, - last_part_boundary: Option>>, -} - -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 Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> { - let mut headers = Headers::new(); - headers.set(ContentType(mime_type)); - headers.set(ContentLength(size)); - 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.len() == 0 && 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.len() == 0 && self.current_part.is_some() - } -} - -impl<'a> Read for MultiPartReader<'a> { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - 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::::new()); - (write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING, - headers, 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).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<'a>(&'a self) -> &'a Mime { &self.0 } -} -impl ::std::ops::DerefMut for XUploadContentType { - fn deref_mut<'a>(&'a mut self) -> &'a mut Mime { &mut self.0 } -} -impl Header for XUploadContentType { - fn header_name() -> &'static str { "X-Upload-Content-Type" } - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - hyper::header::parsing::from_one_raw_str(raw).map(XUploadContentType) - } -} -impl HeaderFormat for XUploadContentType { - fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&**self, f) - } -} -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 { - 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, - pub total_length: u64, -} - -impl Header for ContentRange { - fn header_name() -> &'static str { - "Content-Range" - } - - /// We are not parsable, as parsing is done by the `Range` header - fn parse_header(_: &[Vec]) -> hyper::error::Result { - Err(hyper::error::Error::Method) - } -} - - -impl HeaderFormat for ContentRange { - fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes ")); - match self.range { - Some(ref c) => try!(c.fmt(fmt)), - None => try!(fmt.write_str("*")) - } - (write!(fmt, "/{}", self.total_length)).ok(); - Ok(()) - } -} - -#[derive(Clone, PartialEq, Debug)] -pub struct RangeResponseHeader(pub Chunk); - -impl Header for RangeResponseHeader { - fn header_name() -> &'static str { - "Range" - } - - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - if raw.len() > 0 { - let v = &raw[0]; - if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes "; - if s.starts_with(PREFIX) { - if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { - return Ok(RangeResponseHeader(c)) - } - } - } - } - Err(hyper::error::Error::Method) - } -} - -impl HeaderFormat for RangeResponseHeader { - /// No implmentation necessary, we just need to parse - fn fmt_header(&self, _: &mut fmt::Formatter) -> fmt::Result { - Err(fmt::Error) - } -} - -/// A utility type to perform a resumable upload from start to end. -pub struct ResumableUploadHelper<'a, A: 'a> { - pub client: &'a mut hyper::client::Client, - pub delegate: &'a mut Delegate, - pub start_at: Option, - pub auth: &'a mut A, - pub user_agent: &'a str, - pub auth_header: Authorization, - pub url: &'a str, - pub reader: &'a mut ReadSeek, - pub media_type: Mime, - pub content_length: u64 -} - -impl<'a, A> ResumableUploadHelper<'a, A> - where A: oauth2::GetToken { - - fn query_transfer_status(&mut self) -> std::result::Result> { - loop { - match self.client.post(self.url) - .header(UserAgent(self.user_agent.to_string())) - .header(ContentRange { range: None, total_length: self.content_length }) - .header(self.auth_header.clone()) - .send() { - Ok(r) => { - // 308 = resume-incomplete == PermanentRedirect - let headers = r.headers.clone(); - let h: &RangeResponseHeader = match headers.get() { - Some(hh) if r.status == StatusCode::PermanentRedirect => hh, - None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None, 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 fn upload(&mut self) -> Option> { - let mut start = match self.start_at { - Some(s) => s, - None => match self.query_transfer_status() { - 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 - }; - - self.reader.seek(SeekFrom::Start(start)).unwrap(); - loop { - 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 range_header = ContentRange { - range: Some(Chunk {first: start, last: start + request_size - 1}), - total_length: self.content_length - }; - start += request_size; - if self.delegate.cancel_chunk_upload(&range_header) { - return None - } - let res = self.client.post(self.url) - .header(range_header) - .header(ContentType(self.media_type.clone())) - .header(UserAgent(self.user_agent.to_string())) - .body(&mut section_reader) - .send(); - match res { - Ok(mut res) => { - if res.status == StatusCode::PermanentRedirect { - continue - } - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - } - return Some(Ok(res)) - }, - Err(err) => { - if let Retry::After(d) = self.delegate.http_error(&err) { - sleep(d); - continue; - } - return Some(Err(err)) - } - } - } - } -} - -// Copy of src/rust/cli/cmn.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); - } - } - _ => {} - } -} diff --git a/gen/freebase1/src/lib.rs b/gen/freebase1/src/lib.rs deleted file mode 100644 index 80356e7942..0000000000 --- a/gen/freebase1/src/lib.rs +++ /dev/null @@ -1,193 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.mako' -// DO NOT EDIT ! - -//! This documentation was generated from *freebase* crate version *0.1.14+20150728*, where *20150728* is the exact revision of the *freebase:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. -//! -//! Everything else about the *freebase* *v1* API can be found at the -//! [official documentation site](https://developers.google.com/freebase/). -//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/freebase1). -//! # Features -//! -//! Use the following functionality with ease from the central [hub](struct.Freebase.html) ... -//! -//! -//! * [reconcile](struct.MethodReconcileCall.html) -//! * [search](struct.MethodSearchCall.html) -//! -//! Download supported by ... -//! -//! * [*search*](struct.MethodSearchCall.html) -//! -//! -//! -//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html). -//! -//! # Structure of this Library -//! -//! The API is structured into the following primary items: -//! -//! * **[Hub](struct.Freebase.html)** -//! * a central object to maintain state and allow accessing all *Activities* -//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn -//! allow access to individual [*Call Builders*](trait.CallBuilder.html) -//! * **[Resources](trait.Resource.html)** -//! * primary types that you can apply *Activities* to -//! * a collection of properties and *Parts* -//! * **[Parts](trait.Part.html)** -//! * a collection of properties -//! * never directly used in *Activities* -//! * **[Activities](trait.CallBuilder.html)** -//! * 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() -//! ``` -//! -//! Or specifically ... -//! -//! ```ignore -//! let r = hub.methods().reconcile(...).doit() -//! ``` -//! -//! 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-freebase1 = "*" -//! ``` -//! -//! ## A complete example -//! -//! ```test_harness,no_run -//! extern crate hyper; -//! extern crate yup_oauth2 as oauth2; -//! extern crate google_freebase1 as freebase1; -//! use freebase1::{Result, Error}; -//! # #[test] fn egal() { -//! use std::default::Default; -//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use freebase1::Freebase; -//! -//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and -//! // `client_secret`, among other things. -//! let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -//! hyper::Client::new(), -//! ::default(), None); -//! let mut hub = Freebase::new(hyper::Client::new(), auth); -//! // 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.methods().reconcile() -//! .add_prop("labore") -//! .name("eirmod") -//! .limit(-33) -//! .add_lang("invidunt") -//! .add_kind("aliquyam") -//! .confidence(0.284925834809) -//! .doit(); -//! -//! 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::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](enum.Result.html) enumeration as return value of -//! the doit() methods, or handed as possibly intermediate results to either the -//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../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](enum.Result.html), should be -//! read by you to obtain the media. -//! If such a method also supports a [Response Result](trait.ResponseResult.html), 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](trait.Delegate.html) to the -//! [Method Builder](trait.CallBuilder.html) 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](trait.Delegate.html) 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 [enocodable](trait.RequestValue.html) and -//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -//! are valid. -//! Most optionals are are considered [Parts](trait.Part.html) 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](trait.CallBuilder.html), 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](trait.RequestValue.html) 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 ... . -#![cfg_attr(feature = "nightly", feature(custom_derive, custom_attribute, plugin))] -#![cfg_attr(feature = "nightly", plugin(serde_macros))] -#![allow(unused_imports, unused_mut, dead_code)] - -#[cfg(feature = "nightly")] -include!("lib.rs.in"); - -#[cfg(feature = "with-serde-codegen")] -include!(concat!(env!("OUT_DIR"), "/lib.rs")); \ No newline at end of file diff --git a/gen/freebase1/src/lib.rs.in b/gen/freebase1/src/lib.rs.in deleted file mode 100644 index 57aa9e9ebd..0000000000 --- a/gen/freebase1/src/lib.rs.in +++ /dev/null @@ -1,1066 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.in.mako' -// DO NOT EDIT ! - -extern crate hyper; -extern crate serde; -extern crate serde_json; -extern crate yup_oauth2 as oauth2; -extern crate mime; -extern crate url; - -mod cmn; - -use std::collections::HashMap; -use std::cell::RefCell; -use std::borrow::BorrowMut; -use std::default::Default; -use std::collections::BTreeMap; -use serde_json as json; -use std::io; -use std::fs; -use std::thread::sleep; -use std::time::Duration; - -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, - ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, - Resource, ErrorResponse, remove_json_null_values}; - - -// ############## -// UTILITIES ### -// ############ - - - - -// ######## -// HUB ### -// ###### - -/// Central instance to access all Freebase related resource activities -/// -/// # Examples -/// -/// Instantiate a new hub -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_freebase1 as freebase1; -/// use freebase1::{Result, Error}; -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use freebase1::Freebase; -/// -/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and -/// // `client_secret`, among other things. -/// let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Freebase::new(hyper::Client::new(), auth); -/// // 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.methods().reconcile() -/// .add_prop("kasd") -/// .name("accusam") -/// .limit(-8) -/// .add_lang("justo") -/// .add_kind("amet.") -/// .confidence(0.204946002078) -/// .doit(); -/// -/// 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::MissingAPIKey -/// |Error::MissingToken(_) -/// |Error::Cancelled -/// |Error::UploadSizeLimitExceeded(_, _) -/// |Error::Failure(_) -/// |Error::BadRequest(_) -/// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_, _) => println!("{}", e), -/// }, -/// Ok(res) => println!("Success: {:?}", res), -/// } -/// # } -/// ``` -pub struct Freebase { - client: RefCell, - auth: RefCell, - _user_agent: String, -} - -impl<'a, C, A> Hub for Freebase {} - -impl<'a, C, A> Freebase - where C: BorrowMut, A: oauth2::GetToken { - - pub fn new(client: C, authenticator: A) -> Freebase { - Freebase { - client: RefCell::new(client), - auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.14".to_string(), - } - } - - pub fn methods(&'a self) -> MethodMethods<'a, C, A> { - MethodMethods { hub: &self } - } - - /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.14`. - /// - /// Returns the previously set user-agent. - pub fn user_agent(&mut self, agent_name: String) -> String { - let prev = self._user_agent.clone(); - self._user_agent = agent_name; - prev - } -} - - -// ############ -// SCHEMAS ### -// ########## -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ReconcileCandidate { - /// Language code that candidate and notable names are displayed in. - pub lang: Option, - /// Percentage likelihood that this candidate is the unique matching entity. Value will be between 0.0 and 1.0 - pub confidence: Option, - /// Type or profession the candidate is notable for. - pub notable: Option, - /// Freebase MID of candidate entity. - pub mid: Option, - /// Freebase name of matching entity in specified language. - pub name: Option, -} - -impl Part for ReconcileCandidate {} - - -/// If filled, then there were recoverable problems that affected the request. For example, some of the properties were ignored because they either are not valid Freebase predicates or are not indexed for reconciliation. The candidates returned should be considered valid results, with the caveat that sections of the request were ignored as specified by the warning text. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ReconcileGetWarning { - /// Code for identifying classes of warnings. - pub reason: Option, - /// Warning message to display to the user. - pub message: Option, - /// Location of warning in the request e.g. invalid predicate. - pub location: Option, -} - -impl NestedType for ReconcileGetWarning {} -impl Part for ReconcileGetWarning {} - - -/// Server costs for reconciling. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ReconcileGetCosts { - /// Total number of hits found. - pub hits: Option, - /// Total milliseconds spent. - pub ms: Option, -} - -impl NestedType for ReconcileGetCosts {} -impl Part for ReconcileGetCosts {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [reconcile](struct.MethodReconcileCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ReconcileGet { - /// Server costs for reconciling. - pub costs: Option, - /// If filled, then there were recoverable problems that affected the request. For example, some of the properties were ignored because they either are not valid Freebase predicates or are not indexed for reconciliation. The candidates returned should be considered valid results, with the caveat that sections of the request were ignored as specified by the warning text. - pub warning: Option>, - /// If filled, then the listed candidates are potential matches, and such should be evaluated by a more discerning algorithm or human. The matches are ordered by confidence. - pub candidate: Option>, - /// If filled, this entity is guaranteed to match at requested confidence probability (default 99%). - #[serde(rename="match")] - pub match_: Option, -} - -impl ResponseResult for ReconcileGet {} - - -/// Type or profession the candidate is notable for. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ReconcileCandidateNotable { - /// MID of notable category. - pub id: Option, - /// Name of notable category in specified language. - pub name: Option, -} - -impl NestedType for ReconcileCandidateNotable {} -impl Part for ReconcileCandidateNotable {} - - - -// ################### -// MethodBuilders ### -// ################# - -/// A builder providing access to all free methods, which are not associated with a particular resource. -/// It is not used directly, but through the `Freebase` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_freebase1 as freebase1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use freebase1::Freebase; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Freebase::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `reconcile(...)` and `search(...)` -/// // to build up your call. -/// let rb = hub.methods(); -/// # } -/// ``` -pub struct MethodMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Freebase, -} - -impl<'a, C, A> MethodsBuilder for MethodMethods<'a, C, A> {} - -impl<'a, C, A> MethodMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Reconcile entities to Freebase open data. - pub fn reconcile(&self) -> MethodReconcileCall<'a, C, A> { - MethodReconcileCall { - hub: self.hub, - _prop: Default::default(), - _name: Default::default(), - _limit: Default::default(), - _lang: Default::default(), - _kind: Default::default(), - _confidence: Default::default(), - _delegate: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Search Freebase open data. - pub fn search(&self) -> MethodSearchCall<'a, C, A> { - MethodSearchCall { - hub: self.hub, - _without: Default::default(), - _with: Default::default(), - _type_: Default::default(), - _stemmed: Default::default(), - _spell: Default::default(), - _scoring: Default::default(), - _query: Default::default(), - _prefixed: Default::default(), - _output: Default::default(), - _mql_output: Default::default(), - _mid: Default::default(), - _limit: Default::default(), - _lang: Default::default(), - _indent: Default::default(), - _help: Default::default(), - _format: Default::default(), - _filter: Default::default(), - _exact: Default::default(), - _encode: Default::default(), - _domain: Default::default(), - _cursor: Default::default(), - _callback: Default::default(), - _as_of_time: Default::default(), - _delegate: Default::default(), - _additional_params: Default::default(), - } - } -} - - - - - -// ################### -// CallBuilders ### -// ################# - -/// Reconcile entities to Freebase open data. -/// -/// A builder for the *reconcile* method. -/// It is not used directly, but through a `MethodMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_freebase1 as freebase1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use freebase1::Freebase; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Freebase::new(hyper::Client::new(), auth); -/// // 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.methods().reconcile() -/// .add_prop("labore") -/// .name("sea") -/// .limit(-90) -/// .add_lang("dolores") -/// .add_kind("gubergren") -/// .confidence(0.0653431304201) -/// .doit(); -/// # } -/// ``` -pub struct MethodReconcileCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Freebase, - _prop: Vec, - _name: Option, - _limit: Option, - _lang: Vec, - _kind: Vec, - _confidence: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, -} - -impl<'a, C, A> CallBuilder for MethodReconcileCall<'a, C, A> {} - -impl<'a, C, A> MethodReconcileCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ReconcileGet)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "freebase.reconcile", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); - if self._prop.len() > 0 { - for f in self._prop.iter() { - params.push(("prop", f.to_string())); - } - } - if let Some(value) = self._name { - params.push(("name", value.to_string())); - } - if let Some(value) = self._limit { - params.push(("limit", value.to_string())); - } - if self._lang.len() > 0 { - for f in self._lang.iter() { - params.push(("lang", f.to_string())); - } - } - if self._kind.len() > 0 { - for f in self._kind.iter() { - params.push(("kind", f.to_string())); - } - } - if let Some(value) = self._confidence { - params.push(("confidence", value.to_string())); - } - for &field in ["alt", "prop", "name", "limit", "lang", "kind", "confidence"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/freebase/v1/reconcile".to_string(); - - let mut key = self.hub.auth.borrow_mut().api_key(); - if key.is_none() { - key = dlg.api_key(); - } - match key { - Some(value) => params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Property values for entity formatted as - /// : - /// - /// Append the given value to the *prop* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_prop(mut self, new_value: &str) -> MethodReconcileCall<'a, C, A> { - self._prop.push(new_value.to_string()); - self - } - /// Name of entity. - /// - /// Sets the *name* query property to the given value. - pub fn name(mut self, new_value: &str) -> MethodReconcileCall<'a, C, A> { - self._name = Some(new_value.to_string()); - self - } - /// Maximum number of candidates to return. - /// - /// Sets the *limit* query property to the given value. - pub fn limit(mut self, new_value: i32) -> MethodReconcileCall<'a, C, A> { - self._limit = Some(new_value); - self - } - /// Languages for names and values. First language is used for display. Default is 'en'. - /// - /// Append the given value to the *lang* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_lang(mut self, new_value: &str) -> MethodReconcileCall<'a, C, A> { - self._lang.push(new_value.to_string()); - self - } - /// Classifications of entity e.g. type, category, title. - /// - /// Append the given value to the *kind* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_kind(mut self, new_value: &str) -> MethodReconcileCall<'a, C, A> { - self._kind.push(new_value.to_string()); - self - } - /// Required confidence for a candidate to match. Must be between .5 and 1.0 - /// - /// Sets the *confidence* query property to the given value. - pub fn confidence(mut self, new_value: f32) -> MethodReconcileCall<'a, C, A> { - self._confidence = Some(new_value); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> MethodReconcileCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> MethodReconcileCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - -} - - -/// Search Freebase open data. -/// -/// This method supports **media download**. To enable it, adjust the builder like this: -/// `.param("alt", "media")`. -/// -/// A builder for the *search* method. -/// It is not used directly, but through a `MethodMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_freebase1 as freebase1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use freebase1::Freebase; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Freebase::new(hyper::Client::new(), auth); -/// // 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.methods().search() -/// .add_without("aliquyam") -/// .add_with("ea") -/// .add_type("no") -/// .stemmed(true) -/// .spell("justo") -/// .scoring("et") -/// .query("et") -/// .prefixed(true) -/// .output("ipsum") -/// .mql_output("Lorem") -/// .add_mid("et") -/// .limit(-70) -/// .add_lang("aliquyam") -/// .indent(true) -/// .help("Lorem") -/// .format("eos") -/// .add_filter("erat") -/// .exact(false) -/// .encode("dolor") -/// .add_domain("eirmod") -/// .cursor(-43) -/// .callback("amet") -/// .as_of_time("no") -/// .doit(); -/// # } -/// ``` -pub struct MethodSearchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Freebase, - _without: Vec, - _with: Vec, - _type_: Vec, - _stemmed: Option, - _spell: Option, - _scoring: Option, - _query: Option, - _prefixed: Option, - _output: Option, - _mql_output: Option, - _mid: Vec, - _limit: Option, - _lang: Vec, - _indent: Option, - _help: Option, - _format: Option, - _filter: Vec, - _exact: Option, - _encode: Option, - _domain: Vec, - _cursor: Option, - _callback: Option, - _as_of_time: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, -} - -impl<'a, C, A> CallBuilder for MethodSearchCall<'a, C, A> {} - -impl<'a, C, A> MethodSearchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "freebase.search", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((24 + self._additional_params.len())); - if self._without.len() > 0 { - for f in self._without.iter() { - params.push(("without", f.to_string())); - } - } - if self._with.len() > 0 { - for f in self._with.iter() { - params.push(("with", f.to_string())); - } - } - if self._type_.len() > 0 { - for f in self._type_.iter() { - params.push(("type", f.to_string())); - } - } - if let Some(value) = self._stemmed { - params.push(("stemmed", value.to_string())); - } - if let Some(value) = self._spell { - params.push(("spell", value.to_string())); - } - if let Some(value) = self._scoring { - params.push(("scoring", value.to_string())); - } - if let Some(value) = self._query { - params.push(("query", value.to_string())); - } - if let Some(value) = self._prefixed { - params.push(("prefixed", value.to_string())); - } - if let Some(value) = self._output { - params.push(("output", value.to_string())); - } - if let Some(value) = self._mql_output { - params.push(("mql_output", value.to_string())); - } - if self._mid.len() > 0 { - for f in self._mid.iter() { - params.push(("mid", f.to_string())); - } - } - if let Some(value) = self._limit { - params.push(("limit", value.to_string())); - } - if self._lang.len() > 0 { - for f in self._lang.iter() { - params.push(("lang", f.to_string())); - } - } - if let Some(value) = self._indent { - params.push(("indent", value.to_string())); - } - if let Some(value) = self._help { - params.push(("help", value.to_string())); - } - if let Some(value) = self._format { - params.push(("format", value.to_string())); - } - if self._filter.len() > 0 { - for f in self._filter.iter() { - params.push(("filter", f.to_string())); - } - } - if let Some(value) = self._exact { - params.push(("exact", value.to_string())); - } - if let Some(value) = self._encode { - params.push(("encode", value.to_string())); - } - if self._domain.len() > 0 { - for f in self._domain.iter() { - params.push(("domain", f.to_string())); - } - } - if let Some(value) = self._cursor { - params.push(("cursor", value.to_string())); - } - if let Some(value) = self._callback { - params.push(("callback", value.to_string())); - } - if let Some(value) = self._as_of_time { - params.push(("as_of_time", value.to_string())); - } - for &field in ["without", "with", "type", "stemmed", "spell", "scoring", "query", "prefixed", "output", "mql_output", "mid", "limit", "lang", "indent", "help", "format", "filter", "exact", "encode", "domain", "cursor", "callback", "as_of_time"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - - let mut url = "https://www.googleapis.com/freebase/v1/search".to_string(); - - let mut key = self.hub.auth.borrow_mut().api_key(); - if key.is_none() { - key = dlg.api_key(); - } - match key { - Some(value) => params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = res; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// A rule to not match against. - /// - /// Append the given value to the *without* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_without(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._without.push(new_value.to_string()); - self - } - /// A rule to match against. - /// - /// Append the given value to the *with* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_with(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._with.push(new_value.to_string()); - self - } - /// Restrict to topics with this Freebase type id. - /// - /// Append the given value to the *type* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_type(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._type_.push(new_value.to_string()); - self - } - /// Query on stemmed names and aliases. May not be used with prefixed. - /// - /// Sets the *stemmed* query property to the given value. - pub fn stemmed(mut self, new_value: bool) -> MethodSearchCall<'a, C, A> { - self._stemmed = Some(new_value); - self - } - /// Request 'did you mean' suggestions - /// - /// Sets the *spell* query property to the given value. - pub fn spell(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._spell = Some(new_value.to_string()); - self - } - /// Relevance scoring algorithm to use. - /// - /// Sets the *scoring* query property to the given value. - pub fn scoring(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._scoring = Some(new_value.to_string()); - self - } - /// Query term to search for. - /// - /// Sets the *query* query property to the given value. - pub fn query(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._query = Some(new_value.to_string()); - self - } - /// Prefix match against names and aliases. - /// - /// Sets the *prefixed* query property to the given value. - pub fn prefixed(mut self, new_value: bool) -> MethodSearchCall<'a, C, A> { - self._prefixed = Some(new_value); - self - } - /// An output expression to request data from matches. - /// - /// Sets the *output* query property to the given value. - pub fn output(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._output = Some(new_value.to_string()); - self - } - /// The MQL query to run againist the results to extract more data. - /// - /// Sets the *mql_output* query property to the given value. - pub fn mql_output(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._mql_output = Some(new_value.to_string()); - self - } - /// A mid to use instead of a query. - /// - /// Append the given value to the *mid* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_mid(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._mid.push(new_value.to_string()); - self - } - /// Maximum number of results to return. - /// - /// Sets the *limit* query property to the given value. - pub fn limit(mut self, new_value: i32) -> MethodSearchCall<'a, C, A> { - self._limit = Some(new_value); - self - } - /// The code of the language to run the query with. Default is 'en'. - /// - /// Append the given value to the *lang* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_lang(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._lang.push(new_value.to_string()); - self - } - /// Whether to indent the json results or not. - /// - /// Sets the *indent* query property to the given value. - pub fn indent(mut self, new_value: bool) -> MethodSearchCall<'a, C, A> { - self._indent = Some(new_value); - self - } - /// The keyword to request help on. - /// - /// Sets the *help* query property to the given value. - pub fn help(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._help = Some(new_value.to_string()); - self - } - /// Structural format of the json response. - /// - /// Sets the *format* query property to the given value. - pub fn format(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._format = Some(new_value.to_string()); - self - } - /// A filter to apply to the query. - /// - /// Append the given value to the *filter* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_filter(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._filter.push(new_value.to_string()); - self - } - /// Query on exact name and keys only. - /// - /// Sets the *exact* query property to the given value. - pub fn exact(mut self, new_value: bool) -> MethodSearchCall<'a, C, A> { - self._exact = Some(new_value); - self - } - /// The encoding of the response. You can use this parameter to enable html encoding. - /// - /// Sets the *encode* query property to the given value. - pub fn encode(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._encode = Some(new_value.to_string()); - self - } - /// Restrict to topics with this Freebase domain id. - /// - /// Append the given value to the *domain* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_domain(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._domain.push(new_value.to_string()); - self - } - /// The cursor value to use for the next page of results. - /// - /// Sets the *cursor* query property to the given value. - pub fn cursor(mut self, new_value: i32) -> MethodSearchCall<'a, C, A> { - self._cursor = Some(new_value); - self - } - /// JS method name for JSONP callbacks. - /// - /// Sets the *callback* query property to the given value. - pub fn callback(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._callback = Some(new_value.to_string()); - self - } - /// A mql as_of_time value to use with mql_output queries. - /// - /// Sets the *as_of_time* query property to the given value. - pub fn as_of_time(mut self, new_value: &str) -> MethodSearchCall<'a, C, A> { - self._as_of_time = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> MethodSearchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> MethodSearchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - -} - - diff --git a/gen/fusiontables2-cli/Cargo.toml b/gen/fusiontables2-cli/Cargo.toml index ed39132c02..f6edd31ebc 100644 --- a/gen/fusiontables2-cli/Cargo.toml +++ b/gen/fusiontables2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-fusiontables2-cli" -version = "0.3.6+20160526" +version = "1.0.0+20160526" authors = ["Sebastian Thiel "] description = "A complete library to interact with fusiontables (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/fusiontables2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-fusiontables2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-fusiontables2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-fusiontables2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-fusiontables2] path = "../fusiontables2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/fusiontables2-cli/README.md b/gen/fusiontables2-cli/README.md index ae058517dd..864a2c3ccd 100644 --- a/gen/fusiontables2-cli/README.md +++ b/gen/fusiontables2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *fusiontables* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/fusiontables2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/fusiontables2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/fusiontables2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/fusiontables2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/fusiontables2-cli). # Usage -This documentation was generated from the *fusiontables* API at revision *20160526*. The CLI is at version *0.3.6*. +This documentation was generated from the *fusiontables* API at revision *20160526*. The CLI is at version *1.0.0*. ```bash fusiontables2 [options] diff --git a/gen/fusiontables2-cli/mkdocs.yml b/gen/fusiontables2-cli/mkdocs.yml index c45070400c..73025b6200 100644 --- a/gen/fusiontables2-cli/mkdocs.yml +++ b/gen/fusiontables2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: fusiontables v0.3.6+20160526 +site_name: fusiontables v1.0.0+20160526 site_url: http://byron.github.io/google-apis-rs/google-fusiontables2-cli site_description: Write integrating applications with bcore diff --git a/gen/fusiontables2-cli/src/main.rs b/gen/fusiontables2-cli/src/main.rs index 11fa8875ac..ee1905b8cb 100644 --- a/gen/fusiontables2-cli/src/main.rs +++ b/gen/fusiontables2-cli/src/main.rs @@ -3585,7 +3585,7 @@ fn main() { let mut app = App::new("fusiontables2") .author("Sebastian Thiel ") - .version("0.3.6+20160526") + .version("1.0.0+20160526") .about("API for working with Fusion Tables data.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_fusiontables2_cli") .arg(Arg::with_name("url") diff --git a/gen/games1-cli/Cargo.toml b/gen/games1-cli/Cargo.toml index e3aed6a2d7..85e985b29f 100644 --- a/gen/games1-cli/Cargo.toml +++ b/gen/games1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-games1-cli" -version = "0.3.6+20160901" +version = "1.0.0+20160901" authors = ["Sebastian Thiel "] description = "A complete library to interact with Games (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/games1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-games1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-games1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-games1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-games1] path = "../games1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/games1-cli/README.md b/gen/games1-cli/README.md index 55147ae717..83b2f1c017 100644 --- a/gen/games1-cli/README.md +++ b/gen/games1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Games* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/games1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/games1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/games1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/games1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/games1-cli). # Usage -This documentation was generated from the *Games* API at revision *20160901*. The CLI is at version *0.3.6*. +This documentation was generated from the *Games* API at revision *20160901*. The CLI is at version *1.0.0*. ```bash games1 [options] diff --git a/gen/games1-cli/mkdocs.yml b/gen/games1-cli/mkdocs.yml index 713aa0562f..ae47220fca 100644 --- a/gen/games1-cli/mkdocs.yml +++ b/gen/games1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Games v0.3.6+20160901 +site_name: Games v1.0.0+20160901 site_url: http://byron.github.io/google-apis-rs/google-games1-cli site_description: Write integrating applications with bcore diff --git a/gen/games1-cli/src/main.rs b/gen/games1-cli/src/main.rs index 83e97709d0..dcc93bb59f 100644 --- a/gen/games1-cli/src/main.rs +++ b/gen/games1-cli/src/main.rs @@ -5259,7 +5259,7 @@ fn main() { let mut app = App::new("games1") .author("Sebastian Thiel ") - .version("0.3.6+20160901") + .version("1.0.0+20160901") .about("The API for Google Play Game Services.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_games1_cli") .arg(Arg::with_name("url") diff --git a/gen/gamesconfiguration1_configuration-cli/Cargo.toml b/gen/gamesconfiguration1_configuration-cli/Cargo.toml index a7c789df05..d9dd0dee3c 100644 --- a/gen/gamesconfiguration1_configuration-cli/Cargo.toml +++ b/gen/gamesconfiguration1_configuration-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gamesconfiguration1_configuration-cli" -version = "0.3.6+20160901" +version = "1.0.0+20160901" authors = ["Sebastian Thiel "] description = "A complete library to interact with Games Configuration (protocol v1configuration)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gamesconfiguration1_configuration-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-gamesconfiguration1_configuration/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-gamesconfiguration1_configuration/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-gamesconfiguration1_configuration/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-gamesconfiguration1_configuration] path = "../gamesconfiguration1_configuration" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/gamesconfiguration1_configuration-cli/README.md b/gen/gamesconfiguration1_configuration-cli/README.md index f2cd023987..a20458c39b 100644 --- a/gen/gamesconfiguration1_configuration-cli/README.md +++ b/gen/gamesconfiguration1_configuration-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Games Configuration* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/gamesconfiguration1-configuration.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/gamesconfiguration1-configuration.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/gamesconfiguration1-configuration.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/gamesconfiguration1-configuration.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/gamesconfiguration1_configuration-cli). # Usage -This documentation was generated from the *Games Configuration* API at revision *20160901*. The CLI is at version *0.3.6*. +This documentation was generated from the *Games Configuration* API at revision *20160901*. The CLI is at version *1.0.0*. ```bash gamesconfiguration1-configuration [options] diff --git a/gen/gamesconfiguration1_configuration-cli/mkdocs.yml b/gen/gamesconfiguration1_configuration-cli/mkdocs.yml index 4d5342d242..fc56c5bfaa 100644 --- a/gen/gamesconfiguration1_configuration-cli/mkdocs.yml +++ b/gen/gamesconfiguration1_configuration-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Games Configuration v0.3.6+20160901 +site_name: Games Configuration v1.0.0+20160901 site_url: http://byron.github.io/google-apis-rs/google-gamesconfiguration1_configuration-cli site_description: Write integrating applications with bcore diff --git a/gen/gamesconfiguration1_configuration-cli/src/main.rs b/gen/gamesconfiguration1_configuration-cli/src/main.rs index ac9b66dd15..cb1e852303 100644 --- a/gen/gamesconfiguration1_configuration-cli/src/main.rs +++ b/gen/gamesconfiguration1_configuration-cli/src/main.rs @@ -1551,7 +1551,7 @@ fn main() { let mut app = App::new("gamesconfiguration1-configuration") .author("Sebastian Thiel ") - .version("0.3.6+20160901") + .version("1.0.0+20160901") .about("The Publishing API for Google Play Game Services.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_gamesconfiguration1_configuration_cli") .arg(Arg::with_name("url") diff --git a/gen/gamesmanagement1_management-cli/Cargo.toml b/gen/gamesmanagement1_management-cli/Cargo.toml index 413870e459..dcc1356679 100644 --- a/gen/gamesmanagement1_management-cli/Cargo.toml +++ b/gen/gamesmanagement1_management-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gamesmanagement1_management-cli" -version = "0.3.6+20160901" +version = "1.0.0+20160901" authors = ["Sebastian Thiel "] description = "A complete library to interact with Games Management (protocol v1management)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gamesmanagement1_management-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-gamesmanagement1_management/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-gamesmanagement1_management/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-gamesmanagement1_management/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-gamesmanagement1_management] path = "../gamesmanagement1_management" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/gamesmanagement1_management-cli/README.md b/gen/gamesmanagement1_management-cli/README.md index 5ac9eb7dca..0d9ce8552c 100644 --- a/gen/gamesmanagement1_management-cli/README.md +++ b/gen/gamesmanagement1_management-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Games Management* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/gamesmanagement1-management.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/gamesmanagement1-management.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/gamesmanagement1-management.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/gamesmanagement1-management.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/gamesmanagement1_management-cli). # Usage -This documentation was generated from the *Games Management* API at revision *20160901*. The CLI is at version *0.3.6*. +This documentation was generated from the *Games Management* API at revision *20160901*. The CLI is at version *1.0.0*. ```bash gamesmanagement1-management [options] diff --git a/gen/gamesmanagement1_management-cli/mkdocs.yml b/gen/gamesmanagement1_management-cli/mkdocs.yml index efa96a2250..42a4c04559 100644 --- a/gen/gamesmanagement1_management-cli/mkdocs.yml +++ b/gen/gamesmanagement1_management-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Games Management v0.3.6+20160901 +site_name: Games Management v1.0.0+20160901 site_url: http://byron.github.io/google-apis-rs/google-gamesmanagement1_management-cli site_description: Write integrating applications with bcore diff --git a/gen/gamesmanagement1_management-cli/src/main.rs b/gen/gamesmanagement1_management-cli/src/main.rs index fbb2e4f5f2..c9b426b030 100644 --- a/gen/gamesmanagement1_management-cli/src/main.rs +++ b/gen/gamesmanagement1_management-cli/src/main.rs @@ -2078,7 +2078,7 @@ fn main() { let mut app = App::new("gamesmanagement1-management") .author("Sebastian Thiel ") - .version("0.3.6+20160901") + .version("1.0.0+20160901") .about("The Management API for Google Play Game Services.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_gamesmanagement1_management_cli") .arg(Arg::with_name("url") diff --git a/gen/gan1_beta1-cli/Cargo.toml b/gen/gan1_beta1-cli/Cargo.toml index 9ec27ded21..a7dd4c62e5 100644 --- a/gen/gan1_beta1-cli/Cargo.toml +++ b/gen/gan1_beta1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gan1_beta1-cli" -version = "0.3.6+20130205" +version = "1.0.0+20130205" authors = ["Sebastian Thiel "] description = "A complete library to interact with gan (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gan1_beta1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-gan1_beta1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-gan1_beta1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-gan1_beta1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-gan1_beta1] path = "../gan1_beta1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/gan1_beta1-cli/README.md b/gen/gan1_beta1-cli/README.md index 2a56495aea..fa733e9f38 100644 --- a/gen/gan1_beta1-cli/README.md +++ b/gen/gan1_beta1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *gan* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/gan1-beta1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/gan1-beta1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/gan1-beta1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/gan1-beta1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/gan1_beta1-cli). # Usage -This documentation was generated from the *gan* API at revision *20130205*. The CLI is at version *0.3.6*. +This documentation was generated from the *gan* API at revision *20130205*. The CLI is at version *1.0.0*. ```bash gan1-beta1 [options] diff --git a/gen/gan1_beta1-cli/mkdocs.yml b/gen/gan1_beta1-cli/mkdocs.yml index 06b4ff3d72..7959f261ce 100644 --- a/gen/gan1_beta1-cli/mkdocs.yml +++ b/gen/gan1_beta1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: gan v0.3.6+20130205 +site_name: gan v1.0.0+20130205 site_url: http://byron.github.io/google-apis-rs/google-gan1_beta1-cli site_description: Write integrating applications with bcore diff --git a/gen/gan1_beta1-cli/src/main.rs b/gen/gan1_beta1-cli/src/main.rs index 5607c350e7..afbef76252 100644 --- a/gen/gan1_beta1-cli/src/main.rs +++ b/gen/gan1_beta1-cli/src/main.rs @@ -1262,7 +1262,7 @@ fn main() { let mut app = App::new("gan1-beta1") .author("Sebastian Thiel ") - .version("0.3.6+20130205") + .version("1.0.0+20130205") .about("Lets you have programmatic access to your Google Affiliate Network data.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_gan1_beta1_cli") .arg(Arg::with_name("folder") diff --git a/gen/genomics1-cli/Cargo.toml b/gen/genomics1-cli/Cargo.toml index 090f6364c0..50fe7b5bc4 100644 --- a/gen/genomics1-cli/Cargo.toml +++ b/gen/genomics1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-genomics1-cli" -version = "0.3.6+20160905" +version = "1.0.0+20160905" authors = ["Sebastian Thiel "] description = "A complete library to interact with genomics (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/genomics1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-genomics1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-genomics1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-genomics1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-genomics1] path = "../genomics1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/genomics1-cli/README.md b/gen/genomics1-cli/README.md index 1191c37250..34d063aab0 100644 --- a/gen/genomics1-cli/README.md +++ b/gen/genomics1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *genomics* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/genomics1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/genomics1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/genomics1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/genomics1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/genomics1-cli). # Usage -This documentation was generated from the *genomics* API at revision *20160905*. The CLI is at version *0.3.6*. +This documentation was generated from the *genomics* API at revision *20160905*. The CLI is at version *1.0.0*. ```bash genomics1 [options] diff --git a/gen/genomics1-cli/mkdocs.yml b/gen/genomics1-cli/mkdocs.yml index c29ae5a5a5..8b29aef4f8 100644 --- a/gen/genomics1-cli/mkdocs.yml +++ b/gen/genomics1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: genomics v0.3.6+20160905 +site_name: genomics v1.0.0+20160905 site_url: http://byron.github.io/google-apis-rs/google-genomics1-cli site_description: Write integrating applications with bcore diff --git a/gen/genomics1-cli/src/main.rs b/gen/genomics1-cli/src/main.rs index be930811b1..bcdc58c5cb 100644 --- a/gen/genomics1-cli/src/main.rs +++ b/gen/genomics1-cli/src/main.rs @@ -6040,7 +6040,7 @@ fn main() { let mut app = App::new("genomics1") .author("Sebastian Thiel ") - .version("0.3.6+20160905") + .version("1.0.0+20160905") .about("Stores, processes, explores and shares genomic data.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_genomics1_cli") .arg(Arg::with_name("url") diff --git a/gen/gmail1-cli/Cargo.toml b/gen/gmail1-cli/Cargo.toml index ea3bf787b4..bf8c9e414c 100644 --- a/gen/gmail1-cli/Cargo.toml +++ b/gen/gmail1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gmail1-cli" -version = "0.3.6+20160711" +version = "1.0.0+20160711" authors = ["Sebastian Thiel "] description = "A complete library to interact with gmail (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/gmail1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-gmail1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-gmail1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-gmail1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-gmail1] path = "../gmail1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/gmail1-cli/README.md b/gen/gmail1-cli/README.md index 309b4bf9c0..3e4a0b2593 100644 --- a/gen/gmail1-cli/README.md +++ b/gen/gmail1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *gmail* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/gmail1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/gmail1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/gmail1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/gmail1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/gmail1-cli). # Usage -This documentation was generated from the *gmail* API at revision *20160711*. The CLI is at version *0.3.6*. +This documentation was generated from the *gmail* API at revision *20160711*. The CLI is at version *1.0.0*. ```bash gmail1 [options] diff --git a/gen/gmail1-cli/mkdocs.yml b/gen/gmail1-cli/mkdocs.yml index 0c6b572165..5bc7f76ab0 100644 --- a/gen/gmail1-cli/mkdocs.yml +++ b/gen/gmail1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: gmail v0.3.6+20160711 +site_name: gmail v1.0.0+20160711 site_url: http://byron.github.io/google-apis-rs/google-gmail1-cli site_description: Write integrating applications with bcore diff --git a/gen/gmail1-cli/src/main.rs b/gen/gmail1-cli/src/main.rs index 70bdbb9d72..70c70343e2 100644 --- a/gen/gmail1-cli/src/main.rs +++ b/gen/gmail1-cli/src/main.rs @@ -5673,7 +5673,7 @@ fn main() { let mut app = App::new("gmail1") .author("Sebastian Thiel ") - .version("0.3.6+20160711") + .version("1.0.0+20160711") .about("Access Gmail mailboxes including sending user email.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_gmail1_cli") .arg(Arg::with_name("url") diff --git a/gen/groupsmigration1-cli/Cargo.toml b/gen/groupsmigration1-cli/Cargo.toml index 9091fb6090..b22a32b9cd 100644 --- a/gen/groupsmigration1-cli/Cargo.toml +++ b/gen/groupsmigration1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-groupsmigration1-cli" -version = "0.3.6+20140416" +version = "1.0.0+20140416" authors = ["Sebastian Thiel "] description = "A complete library to interact with Groups Migration (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/groupsmigration1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-groupsmigration1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-groupsmigration1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-groupsmigration1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-groupsmigration1] path = "../groupsmigration1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/groupsmigration1-cli/README.md b/gen/groupsmigration1-cli/README.md index f8fb893293..5c64e70533 100644 --- a/gen/groupsmigration1-cli/README.md +++ b/gen/groupsmigration1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Groups Migration* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/groupsmigration1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/groupsmigration1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/groupsmigration1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/groupsmigration1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/groupsmigration1-cli). # Usage -This documentation was generated from the *Groups Migration* API at revision *20140416*. The CLI is at version *0.3.6*. +This documentation was generated from the *Groups Migration* API at revision *20140416*. The CLI is at version *1.0.0*. ```bash groupsmigration1 [options] diff --git a/gen/groupsmigration1-cli/mkdocs.yml b/gen/groupsmigration1-cli/mkdocs.yml index 54b29163e3..21364d815c 100644 --- a/gen/groupsmigration1-cli/mkdocs.yml +++ b/gen/groupsmigration1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Groups Migration v0.3.6+20140416 +site_name: Groups Migration v1.0.0+20140416 site_url: http://byron.github.io/google-apis-rs/google-groupsmigration1-cli site_description: Write integrating applications with bcore diff --git a/gen/groupsmigration1-cli/src/main.rs b/gen/groupsmigration1-cli/src/main.rs index 5774c548e7..9e957f9e8e 100644 --- a/gen/groupsmigration1-cli/src/main.rs +++ b/gen/groupsmigration1-cli/src/main.rs @@ -235,7 +235,7 @@ fn main() { let mut app = App::new("groupsmigration1") .author("Sebastian Thiel ") - .version("0.3.6+20140416") + .version("1.0.0+20140416") .about("Groups Migration Api.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_groupsmigration1_cli") .arg(Arg::with_name("url") diff --git a/gen/groupssettings1-cli/Cargo.toml b/gen/groupssettings1-cli/Cargo.toml index e7499498f0..bb26c52e5c 100644 --- a/gen/groupssettings1-cli/Cargo.toml +++ b/gen/groupssettings1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-groupssettings1-cli" -version = "0.3.6+20160525" +version = "1.0.0+20160525" authors = ["Sebastian Thiel "] description = "A complete library to interact with groupssettings (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/groupssettings1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-groupssettings1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-groupssettings1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-groupssettings1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-groupssettings1] path = "../groupssettings1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/groupssettings1-cli/README.md b/gen/groupssettings1-cli/README.md index daf124e7b3..a95b33a9f9 100644 --- a/gen/groupssettings1-cli/README.md +++ b/gen/groupssettings1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *groupssettings* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/groupssettings1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/groupssettings1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/groupssettings1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/groupssettings1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/groupssettings1-cli). # Usage -This documentation was generated from the *groupssettings* API at revision *20160525*. The CLI is at version *0.3.6*. +This documentation was generated from the *groupssettings* API at revision *20160525*. The CLI is at version *1.0.0*. ```bash groupssettings1 [options] diff --git a/gen/groupssettings1-cli/mkdocs.yml b/gen/groupssettings1-cli/mkdocs.yml index a6000a3f2a..a689478caf 100644 --- a/gen/groupssettings1-cli/mkdocs.yml +++ b/gen/groupssettings1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: groupssettings v0.3.6+20160525 +site_name: groupssettings v1.0.0+20160525 site_url: http://byron.github.io/google-apis-rs/google-groupssettings1-cli site_description: Write integrating applications with bcore diff --git a/gen/groupssettings1-cli/src/main.rs b/gen/groupssettings1-cli/src/main.rs index 4703c651e9..0627cd0bd8 100644 --- a/gen/groupssettings1-cli/src/main.rs +++ b/gen/groupssettings1-cli/src/main.rs @@ -516,7 +516,7 @@ fn main() { let mut app = App::new("groupssettings1") .author("Sebastian Thiel ") - .version("0.3.6+20160525") + .version("1.0.0+20160525") .about("Lets you manage permission levels and related settings of a group.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_groupssettings1_cli") .arg(Arg::with_name("url") diff --git a/gen/iam1-cli/Cargo.toml b/gen/iam1-cli/Cargo.toml index 94fce047ce..0704fca099 100644 --- a/gen/iam1-cli/Cargo.toml +++ b/gen/iam1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-iam1-cli" -version = "0.3.6+20160129" +version = "1.0.0+20160129" authors = ["Sebastian Thiel "] description = "A complete library to interact with iam (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/iam1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-iam1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-iam1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-iam1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-iam1] path = "../iam1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/iam1-cli/README.md b/gen/iam1-cli/README.md index d2ac6ce4a7..aeb7869708 100644 --- a/gen/iam1-cli/README.md +++ b/gen/iam1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *iam* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/iam1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/iam1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/iam1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/iam1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/iam1-cli). # Usage -This documentation was generated from the *iam* API at revision *20160129*. The CLI is at version *0.3.6*. +This documentation was generated from the *iam* API at revision *20160129*. The CLI is at version *1.0.0*. ```bash iam1 [options] diff --git a/gen/iam1-cli/mkdocs.yml b/gen/iam1-cli/mkdocs.yml index 48c14d7fad..c663aca39c 100644 --- a/gen/iam1-cli/mkdocs.yml +++ b/gen/iam1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: iam v0.3.6+20160129 +site_name: iam v1.0.0+20160129 site_url: http://byron.github.io/google-apis-rs/google-iam1-cli site_description: Write integrating applications with bcore diff --git a/gen/iam1-cli/src/main.rs b/gen/iam1-cli/src/main.rs index 5e3c5a22b8..619202ee2d 100644 --- a/gen/iam1-cli/src/main.rs +++ b/gen/iam1-cli/src/main.rs @@ -1411,7 +1411,7 @@ fn main() { let mut app = App::new("iam1") .author("Sebastian Thiel ") - .version("0.3.6+20160129") + .version("1.0.0+20160129") .about("Manages identity and access control for Google Cloud Platform resources, including the creation of service accounts, which you can use to authenticate to Google and make API calls.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_iam1_cli") .arg(Arg::with_name("url") diff --git a/gen/identitytoolkit3-cli/Cargo.toml b/gen/identitytoolkit3-cli/Cargo.toml index cf08af50c4..31a1116dd2 100644 --- a/gen/identitytoolkit3-cli/Cargo.toml +++ b/gen/identitytoolkit3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-identitytoolkit3-cli" -version = "0.3.6+20160812" +version = "1.0.0+20160812" authors = ["Sebastian Thiel "] description = "A complete library to interact with Identity Toolkit (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/identitytoolkit3-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-identitytoolkit3/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-identitytoolkit3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-identitytoolkit3/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-identitytoolkit3] path = "../identitytoolkit3" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/identitytoolkit3-cli/README.md b/gen/identitytoolkit3-cli/README.md index 9072ea0b06..27f05357ed 100644 --- a/gen/identitytoolkit3-cli/README.md +++ b/gen/identitytoolkit3-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Identity Toolkit* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/identitytoolkit3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/identitytoolkit3.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/identitytoolkit3.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/identitytoolkit3.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/identitytoolkit3-cli). # Usage -This documentation was generated from the *Identity Toolkit* API at revision *20160812*. The CLI is at version *0.3.6*. +This documentation was generated from the *Identity Toolkit* API at revision *20160812*. The CLI is at version *1.0.0*. ```bash identitytoolkit3 [options] diff --git a/gen/identitytoolkit3-cli/mkdocs.yml b/gen/identitytoolkit3-cli/mkdocs.yml index a24a750cea..b19ec1ce7d 100644 --- a/gen/identitytoolkit3-cli/mkdocs.yml +++ b/gen/identitytoolkit3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Identity Toolkit v0.3.6+20160812 +site_name: Identity Toolkit v1.0.0+20160812 site_url: http://byron.github.io/google-apis-rs/google-identitytoolkit3-cli site_description: Write integrating applications with bcore diff --git a/gen/identitytoolkit3-cli/src/main.rs b/gen/identitytoolkit3-cli/src/main.rs index 027facfa81..a5c12f1574 100644 --- a/gen/identitytoolkit3-cli/src/main.rs +++ b/gen/identitytoolkit3-cli/src/main.rs @@ -1966,7 +1966,7 @@ fn main() { let mut app = App::new("identitytoolkit3") .author("Sebastian Thiel ") - .version("0.3.6+20160812") + .version("1.0.0+20160812") .about("Help the third party sites to implement federated login.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_identitytoolkit3_cli") .arg(Arg::with_name("folder") diff --git a/gen/kgsearch1-cli/Cargo.toml b/gen/kgsearch1-cli/Cargo.toml index 710a95f052..5f8b082a85 100644 --- a/gen/kgsearch1-cli/Cargo.toml +++ b/gen/kgsearch1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-kgsearch1-cli" -version = "0.3.6+20151215" +version = "1.0.0+20151215" authors = ["Sebastian Thiel "] description = "A complete library to interact with kgsearch (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/kgsearch1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-kgsearch1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-kgsearch1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-kgsearch1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-kgsearch1] path = "../kgsearch1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/kgsearch1-cli/README.md b/gen/kgsearch1-cli/README.md index 52c0af8374..714a20870d 100644 --- a/gen/kgsearch1-cli/README.md +++ b/gen/kgsearch1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *kgsearch* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/kgsearch1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/kgsearch1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/kgsearch1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/kgsearch1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/kgsearch1-cli). # Usage -This documentation was generated from the *kgsearch* API at revision *20151215*. The CLI is at version *0.3.6*. +This documentation was generated from the *kgsearch* API at revision *20151215*. The CLI is at version *1.0.0*. ```bash kgsearch1 [options] diff --git a/gen/kgsearch1-cli/mkdocs.yml b/gen/kgsearch1-cli/mkdocs.yml index 586907b4bb..eef137d7b8 100644 --- a/gen/kgsearch1-cli/mkdocs.yml +++ b/gen/kgsearch1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: kgsearch v0.3.6+20151215 +site_name: kgsearch v1.0.0+20151215 site_url: http://byron.github.io/google-apis-rs/google-kgsearch1-cli site_description: Write integrating applications with bcore diff --git a/gen/kgsearch1-cli/src/main.rs b/gen/kgsearch1-cli/src/main.rs index 27de7ce43e..06ebea29dc 100644 --- a/gen/kgsearch1-cli/src/main.rs +++ b/gen/kgsearch1-cli/src/main.rs @@ -241,7 +241,7 @@ fn main() { let mut app = App::new("kgsearch1") .author("Sebastian Thiel ") - .version("0.3.6+20151215") + .version("1.0.0+20151215") .about("Knowledge Graph Search API allows developers to search the Google Knowledge Graph for entities.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_kgsearch1_cli") .arg(Arg::with_name("folder") diff --git a/gen/licensing1-cli/Cargo.toml b/gen/licensing1-cli/Cargo.toml index fe33d7c9ad..214ada363e 100644 --- a/gen/licensing1-cli/Cargo.toml +++ b/gen/licensing1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-licensing1-cli" -version = "0.3.6+20150901" +version = "1.0.0+20150901" authors = ["Sebastian Thiel "] description = "A complete library to interact with licensing (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/licensing1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-licensing1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-licensing1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-licensing1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-licensing1] path = "../licensing1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/licensing1-cli/README.md b/gen/licensing1-cli/README.md index cda48564dd..9eb64e793d 100644 --- a/gen/licensing1-cli/README.md +++ b/gen/licensing1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *licensing* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/licensing1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/licensing1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/licensing1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/licensing1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/licensing1-cli). # Usage -This documentation was generated from the *licensing* API at revision *20150901*. The CLI is at version *0.3.6*. +This documentation was generated from the *licensing* API at revision *20150901*. The CLI is at version *1.0.0*. ```bash licensing1 [options] diff --git a/gen/licensing1-cli/mkdocs.yml b/gen/licensing1-cli/mkdocs.yml index 5413b14193..030c70e315 100644 --- a/gen/licensing1-cli/mkdocs.yml +++ b/gen/licensing1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: licensing v0.3.6+20150901 +site_name: licensing v1.0.0+20150901 site_url: http://byron.github.io/google-apis-rs/google-licensing1-cli site_description: Write integrating applications with bcore diff --git a/gen/licensing1-cli/src/main.rs b/gen/licensing1-cli/src/main.rs index 6ee299f1f0..be5050f81c 100644 --- a/gen/licensing1-cli/src/main.rs +++ b/gen/licensing1-cli/src/main.rs @@ -885,7 +885,7 @@ fn main() { let mut app = App::new("licensing1") .author("Sebastian Thiel ") - .version("0.3.6+20150901") + .version("1.0.0+20150901") .about("Licensing API to view and manage license for your domain.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_licensing1_cli") .arg(Arg::with_name("url") diff --git a/gen/logging2_beta1-cli/Cargo.toml b/gen/logging2_beta1-cli/Cargo.toml index 9d30fbda3c..4fea318d26 100644 --- a/gen/logging2_beta1-cli/Cargo.toml +++ b/gen/logging2_beta1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-logging2_beta1-cli" -version = "0.3.6+20160322" +version = "1.0.0+20160322" authors = ["Sebastian Thiel "] description = "A complete library to interact with logging (protocol v2beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/logging2_beta1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-logging2_beta1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-logging2_beta1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-logging2_beta1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-logging2_beta1] path = "../logging2_beta1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/logging2_beta1-cli/README.md b/gen/logging2_beta1-cli/README.md index 224d3edbfd..9ecae8e95d 100644 --- a/gen/logging2_beta1-cli/README.md +++ b/gen/logging2_beta1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *logging* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/logging2-beta1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/logging2-beta1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/logging2-beta1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/logging2-beta1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/logging2_beta1-cli). # Usage -This documentation was generated from the *logging* API at revision *20160322*. The CLI is at version *0.3.6*. +This documentation was generated from the *logging* API at revision *20160322*. The CLI is at version *1.0.0*. ```bash logging2-beta1 [options] diff --git a/gen/logging2_beta1-cli/mkdocs.yml b/gen/logging2_beta1-cli/mkdocs.yml index de6b488600..2966536968 100644 --- a/gen/logging2_beta1-cli/mkdocs.yml +++ b/gen/logging2_beta1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: logging v0.3.6+20160322 +site_name: logging v1.0.0+20160322 site_url: http://byron.github.io/google-apis-rs/google-logging2_beta1-cli site_description: Write integrating applications with bcore diff --git a/gen/logging2_beta1-cli/src/main.rs b/gen/logging2_beta1-cli/src/main.rs index 6bbcb2b5ea..78aa740b58 100644 --- a/gen/logging2_beta1-cli/src/main.rs +++ b/gen/logging2_beta1-cli/src/main.rs @@ -1507,7 +1507,7 @@ fn main() { let mut app = App::new("logging2-beta1") .author("Sebastian Thiel ") - .version("0.3.6+20160322") + .version("1.0.0+20160322") .about("Writes log entries and manages your logs, log sinks, and logs-based metrics.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_logging2_beta1_cli") .arg(Arg::with_name("url") diff --git a/gen/manager1_beta2-cli/Cargo.toml b/gen/manager1_beta2-cli/Cargo.toml index f404340e14..0071908685 100644 --- a/gen/manager1_beta2-cli/Cargo.toml +++ b/gen/manager1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-manager1_beta2-cli" -version = "0.3.6+20140915" +version = "1.0.0+20140915" authors = ["Sebastian Thiel "] description = "A complete library to interact with manager (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/manager1_beta2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-manager1_beta2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-manager1_beta2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-manager1_beta2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-manager1_beta2] path = "../manager1_beta2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/manager1_beta2-cli/README.md b/gen/manager1_beta2-cli/README.md index f0bc711431..972550739c 100644 --- a/gen/manager1_beta2-cli/README.md +++ b/gen/manager1_beta2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *manager* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/manager1-beta2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/manager1-beta2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/manager1-beta2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/manager1-beta2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/manager1_beta2-cli). # Usage -This documentation was generated from the *manager* API at revision *20140915*. The CLI is at version *0.3.6*. +This documentation was generated from the *manager* API at revision *20140915*. The CLI is at version *1.0.0*. ```bash manager1-beta2 [options] diff --git a/gen/manager1_beta2-cli/mkdocs.yml b/gen/manager1_beta2-cli/mkdocs.yml index 518a26350d..afe0dd8130 100644 --- a/gen/manager1_beta2-cli/mkdocs.yml +++ b/gen/manager1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: manager v0.3.6+20140915 +site_name: manager v1.0.0+20140915 site_url: http://byron.github.io/google-apis-rs/google-manager1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/manager1_beta2-cli/src/main.rs b/gen/manager1_beta2-cli/src/main.rs index 478508df2b..2296ae96a2 100644 --- a/gen/manager1_beta2-cli/src/main.rs +++ b/gen/manager1_beta2-cli/src/main.rs @@ -892,7 +892,7 @@ fn main() { let mut app = App::new("manager1-beta2") .author("Sebastian Thiel ") - .version("0.3.6+20140915") + .version("1.0.0+20140915") .about("The Deployment Manager API allows users to declaratively configure, deploy and run complex solutions on the Google Cloud Platform.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_manager1_beta2_cli") .arg(Arg::with_name("url") diff --git a/gen/mirror1-cli/Cargo.toml b/gen/mirror1-cli/Cargo.toml index 54cd709331..918ce30d23 100644 --- a/gen/mirror1-cli/Cargo.toml +++ b/gen/mirror1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-mirror1-cli" -version = "0.3.6+20160616" +version = "1.0.0+20160616" authors = ["Sebastian Thiel "] description = "A complete library to interact with mirror (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/mirror1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-mirror1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-mirror1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-mirror1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-mirror1] path = "../mirror1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/mirror1-cli/README.md b/gen/mirror1-cli/README.md index 4bdd175fb0..5b033bf9c2 100644 --- a/gen/mirror1-cli/README.md +++ b/gen/mirror1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *mirror* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/mirror1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/mirror1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/mirror1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/mirror1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/mirror1-cli). # Usage -This documentation was generated from the *mirror* API at revision *20160616*. The CLI is at version *0.3.6*. +This documentation was generated from the *mirror* API at revision *20160616*. The CLI is at version *1.0.0*. ```bash mirror1 [options] diff --git a/gen/mirror1-cli/mkdocs.yml b/gen/mirror1-cli/mkdocs.yml index d9043b4ee2..f003c73c94 100644 --- a/gen/mirror1-cli/mkdocs.yml +++ b/gen/mirror1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: mirror v0.3.6+20160616 +site_name: mirror v1.0.0+20160616 site_url: http://byron.github.io/google-apis-rs/google-mirror1-cli site_description: Write integrating applications with bcore diff --git a/gen/mirror1-cli/src/main.rs b/gen/mirror1-cli/src/main.rs index 3bb634e665..faf34df756 100644 --- a/gen/mirror1-cli/src/main.rs +++ b/gen/mirror1-cli/src/main.rs @@ -2563,7 +2563,7 @@ fn main() { let mut app = App::new("mirror1") .author("Sebastian Thiel ") - .version("0.3.6+20160616") + .version("1.0.0+20160616") .about("Interacts with Glass users via the timeline.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_mirror1_cli") .arg(Arg::with_name("url") diff --git a/gen/monitoring3-cli/Cargo.toml b/gen/monitoring3-cli/Cargo.toml index 54bfbc3c68..4ef93ccc29 100644 --- a/gen/monitoring3-cli/Cargo.toml +++ b/gen/monitoring3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-monitoring3-cli" -version = "0.3.6+20160425" +version = "1.0.0+20160425" authors = ["Sebastian Thiel "] description = "A complete library to interact with monitoring (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/monitoring3-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-monitoring3/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-monitoring3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-monitoring3/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-monitoring3] path = "../monitoring3" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/monitoring3-cli/README.md b/gen/monitoring3-cli/README.md index d8c5775d32..141e7ea79f 100644 --- a/gen/monitoring3-cli/README.md +++ b/gen/monitoring3-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *monitoring* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/monitoring3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/monitoring3.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/monitoring3.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/monitoring3.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/monitoring3-cli). # Usage -This documentation was generated from the *monitoring* API at revision *20160425*. The CLI is at version *0.3.6*. +This documentation was generated from the *monitoring* API at revision *20160425*. The CLI is at version *1.0.0*. ```bash monitoring3 [options] diff --git a/gen/monitoring3-cli/mkdocs.yml b/gen/monitoring3-cli/mkdocs.yml index d95b383f3f..991ecfcfac 100644 --- a/gen/monitoring3-cli/mkdocs.yml +++ b/gen/monitoring3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: monitoring v0.3.6+20160425 +site_name: monitoring v1.0.0+20160425 site_url: http://byron.github.io/google-apis-rs/google-monitoring3-cli site_description: Write integrating applications with bcore diff --git a/gen/monitoring3-cli/src/main.rs b/gen/monitoring3-cli/src/main.rs index 4ed4ca5df3..a3468fb353 100644 --- a/gen/monitoring3-cli/src/main.rs +++ b/gen/monitoring3-cli/src/main.rs @@ -1610,7 +1610,7 @@ fn main() { let mut app = App::new("monitoring3") .author("Sebastian Thiel ") - .version("0.3.6+20160425") + .version("1.0.0+20160425") .about("Manages your Stackdriver monitoring data and configurations. Projects must be associated with a Stackdriver account, except for the following methods: [monitoredResourceDescriptors.list](v3/projects.monitoredResourceDescriptors/list), [monitoredResourceDescriptors.get](v3/projects.monitoredResourceDescriptors/get), [metricDescriptors.list](v3/projects.metricDescriptors/list), [metricDescriptors.get](v3/projects.metricDescriptors/get), and [timeSeries.list](v3/projects.timeSeries/list).") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_monitoring3_cli") .arg(Arg::with_name("url") diff --git a/gen/oauth2_v2-cli/Cargo.toml b/gen/oauth2_v2-cli/Cargo.toml deleted file mode 100644 index 3886855d84..0000000000 --- a/gen/oauth2_v2-cli/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-oauth2_v2-cli" -version = "0.3.6+20160330" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with oauth2 (protocol v2)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/oauth2_v2-cli" -homepage = "https://developers.google.com/accounts/docs/OAuth2" -documentation = "http://byron.github.io/google-apis-rs/google_oauth2_v2_cli" -license = "MIT" -keywords = ["oauth2", "google", "cli"] - -[[bin]] -name = "oauth2-v2" - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -strsim = "^0.4" -yup-hyper-mock = "^1.0" -clap = "^2.0" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-oauth2_v2/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-oauth2_v2/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - - -[dependencies.google-oauth2_v2] -path = "../oauth2_v2" -optional = true -default-features = false diff --git a/gen/oauth2_v2-cli/LICENSE.md b/gen/oauth2_v2-cli/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/oauth2_v2-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/oauth2_v2-cli/README.md b/gen/oauth2_v2-cli/README.md deleted file mode 100644 index f839445ed8..0000000000 --- a/gen/oauth2_v2-cli/README.md +++ /dev/null @@ -1,117 +0,0 @@ - -The `oauth2-v2` command-line interface *(CLI)* allows to use most features of the *Google oauth2* service from the comfort of your terminal. - -By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's -capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. - -If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. - -Everything else about the *oauth2* API can be found at the -[official documentation site](https://developers.google.com/accounts/docs/OAuth2). - -# Downloads - -You can download the pre-compiled 64bit binaries for the following platforms: - -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/oauth2-v2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/oauth2-v2.tar.gz) - -Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/oauth2_v2-cli). - -# Usage - -This documentation was generated from the *oauth2* API at revision *20160330*. The CLI is at version *0.3.6*. - -```bash -oauth2-v2 [options] - methods - get-cert-for-open-id-connect [-p ]... [-o ] - tokeninfo [-p ]... [-o ] - userinfo - get [-p ]... [-o ] - v2-me-get [-p ]... [-o ] - oauth2-v2 --help - -Configuration: - [--scope ]... - Specify the authentication a method should be executed in. Each scope - requires the user to grant this application permission to use it. - If unset, it defaults to the shortest scope url for a particular method. - --config-dir - A directory into which we will store our persistent data. Defaults to - a user-writable directory that we will create during the first invocation. - [default: ~/.google-service-cli] - --debug - Output all server communication to standard error. `tx` and `rx` are placed - into the same stream. - --debug-auth - Output all communication related to authentication to standard error. `tx` - and `rx` are placed into the same stream. - -``` - -# Configuration - -The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `oauth2-v2-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. - -More information about the various kinds of persistent data are given in the following paragraphs. - -# Authentication - -Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the -set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. - -If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a -method that is read-only, it will ask only for a read-only scope. -You may use the `--scope` flag to specify a scope directly. -All applicable scopes are documented in the respective method's CLI documentation. - -The first time a scope is used, the user is asked for permission. Follow the instructions given -by the CLI to grant permissions, or to decline. - -If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration -directory, e.g. `~/.google-service-cli/oauth2-v2-token-.json`. No manual management of these tokens -is necessary. - -To revoke granted authentication, please refer to the [official documentation][revoke-access]. - -# Application Secrets - -In order to allow any application to use Google services, it will need to be registered using the -[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it -one by one. Most APIs can be used for free and have a daily quota. - -To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI -comes with a default application secret that is configured accordingly. This also means that heavy usage -all around the world may deplete the daily quota. - -You can workaround this limitation by putting your own secrets file at this location: -`~/.google-service-cli/oauth2-v2-secret.json`, assuming that the required *oauth2* API -was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at -*APIs & auth -> Credentials -> Download JSON* and used as is. - -Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. - - -# Debugging - -Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know -what exactly led to a particular issue. This is done by allowing all client-server communication to be -output to standard error *as-is*. - -The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag -will cause all communication related to authentication to standard error. -If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the -issue at hand. - -You may consider redirecting standard error into a file for ease of use, e.g. `oauth2-v2 --debug [options] 2>debug.txt`. - - -[scopes]: https://developers.google.com/+/api/oauth#scopes -[revoke-access]: http://webapps.stackexchange.com/a/30849 -[google-dev-console]: https://console.developers.google.com/ -[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/oauth2_v2-cli/mkdocs.yml b/gen/oauth2_v2-cli/mkdocs.yml deleted file mode 100644 index ac56ff6c06..0000000000 --- a/gen/oauth2_v2-cli/mkdocs.yml +++ /dev/null @@ -1,20 +0,0 @@ -site_name: oauth2 v0.3.6+20160330 -site_url: http://byron.github.io/google-apis-rs/google-oauth2_v2-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/oauth2_v2-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['methods_get-cert-for-open-id-connect.md', 'Methods', 'Get Cert For Open Id Connect'] -- ['methods_tokeninfo.md', 'Methods', 'Tokeninfo'] -- ['userinfo_get.md', 'Userinfo', 'Get'] -- ['userinfo_v2-me-get.md', 'Userinfo', 'V2 Me Get'] - -theme: readthedocs - -copyright: Copyright © 2015-2016, `Sebastian Thiel` - diff --git a/gen/oauth2_v2-cli/src/cmn.rs b/gen/oauth2_v2-cli/src/cmn.rs deleted file mode 100644 index 779c1dc086..0000000000 --- a/gen/oauth2_v2-cli/src/cmn.rs +++ /dev/null @@ -1,721 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use serde_json as json; -use serde_json::value::Value; -use mime::Mime; -use clap::{App, SubCommand}; -use strsim; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - - -pub enum ComplexType { - Pod, - Vec, - Map, -} - - // Null, - // Bool(bool), - // I64(i64), - // U64(u64), - // F64(f64), - // String(String), - -pub enum JsonType { - Boolean, - Int, - Uint, - Float, - String, -} - -pub struct JsonTypeInfo { - pub jtype: JsonType, - pub ctype: ComplexType, -} - -// Based on @erickt user comment. Thanks for the idea ! -// Remove all keys whose values are null from given value (changed in place) -pub fn remove_json_null_values(value: &mut Value) { - match *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); - } - } - _ => {} - } -} - -fn did_you_mean<'a>(v: &str, possible_values: &[&'a str]) -> Option<&'a str> { - - let mut candidate: Option<(f64, &str)> = None; - for pv in possible_values { - let confidence = strsim::jaro_winkler(v, pv); - if confidence > 0.8 && (candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence)) { - candidate = Some((confidence, pv)); - } - } - match candidate { - None => None, - Some((_, candidate)) => Some(candidate), - } -} - -pub enum CallType { - Upload(UploadProtocol), - Standard, -} - -arg_enum!{ - pub enum UploadProtocol { - Simple, - Resumable - } -} - -impl AsRef for UploadProtocol { - fn as_ref(&self) -> &str { - match *self { - UploadProtocol::Simple => "simple", - UploadProtocol::Resumable => "resumable" - } - } -} - -impl AsRef for CallType { - fn as_ref(&self) -> &str { - match *self { - CallType::Upload(ref proto) => proto.as_ref(), - CallType::Standard => "standard-request" - } - } -} - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.join(".") - } -} - -impl From<&'static str> for FieldCursor { - fn from(value: &'static str) -> FieldCursor { - let mut res = FieldCursor::default(); - res.set(value).unwrap(); - res - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn did_you_mean(value: &str, possible_values: &[&str]) -> Option { - if value.len() == 0 { - return None - } - - let mut last_c = FIELD_SEP; - - let mut field = String::new(); - let mut output = String::new(); - - let push_field = |fs: &mut String, f: &mut String| { - if f.len() > 0 { - fs.push_str( - match did_you_mean(&f, possible_values) { - Some(candidate) => candidate, - None => &f, - }); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - if c == FIELD_SEP { - if last_c != FIELD_SEP { - push_field(&mut output, &mut field); - } - output.push(c); - } else { - field.push(c); - } - - last_c = c; - } - - push_field(&mut output, &mut field); - - if &output == value { - None - } else { - Some(output) - } - } - - pub fn set_json_value(&self, mut object: &mut Value, - value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, - orig_cursor: &FieldCursor) { - assert!(self.0.len() > 0); - - for field in &self.0[..self.0.len()-1] { - let tmp = object; - object = - match *tmp { - Value::Object(ref mut mapping) => { - mapping.entry(field.to_owned()).or_insert( - Value::Object(Default::default()) - ) - }, - _ => panic!("We don't expect non-object Values here ...") - }; - } - - match *object { - Value::Object(ref mut mapping) => { - let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| - -> Value { - match jtype { - JsonType::Boolean => - Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => - Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => - Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => - Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => - Value::String(value.to_owned()), - } - }; - - match type_info.ctype { - ComplexType::Pod => { - if mapping.insert(field.to_owned(), to_jval(value, type_info.jtype, err)).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - }, - ComplexType::Vec => { - match *mapping.entry(field.to_owned()) - .or_insert(Value::Array(Default::default())) { - Value::Array(ref mut values) => values.push(to_jval(value, type_info.jtype, err)), - _ => unreachable!() - } - }, - ComplexType::Map => { - let (key, value) = parse_kv_arg(value, err, true); - let jval = to_jval(value.unwrap_or(""), type_info.jtype, err); - - match *mapping.entry(field.to_owned()) - .or_insert(Value::Object(Default::default())) { - Value::Object(ref mut value_map) => { - if value_map.insert(key.to_owned(), jval).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - } - _ => unreachable!() - } - } - } - }, - _ => unreachable!() - } - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); - match kv.find('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, Some("")) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut InvalidOptionsError) -> CallType { - CallType::Upload( - match UploadProtocol::from_str(name) { - Ok(up) => up, - Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); - UploadProtocol::Simple - } - }) -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::Io((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { - let f = arg.unwrap_or("-"); - match f { - "-" => Ok(Box::new(stdout())), - _ => match fs::OpenOptions::new().create(true).write(true).open(f) { - Ok(f) => Ok(Box::new(f)), - Err(io_err) => Err(io_err), - } - } -} - - -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, - arg_type: &'a str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError(arg_name.to_owned(), arg_type.to_owned(), arg.to_string(), format!("{}", perr)) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - type Error = json::Error; - - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Result<(), json::Error> { - match token { - None => { - match fs::remove_file(self.path(scope_hash)) { - Err(err) => - match err.kind() { - io::ErrorKind::NotFound => Ok(()), - _ => Err(json::Error::Io(err)) - }, - Ok(_) => Ok(()), - } - } - Some(token) => { - match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { - Ok(mut f) => { - match json::to_writer_pretty(&mut f, &token) { - Ok(_) => Ok(()), - Err(serde_err) => Err(serde_err), - } - }, - Err(io_err) => Err(json::Error::Io(io_err)) - } - } - } - } - - fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, json::Error> { - match fs::File::open(&self.path(scope_hash)) { - Ok(f) => { - match json::de::from_reader(f) { - Ok(token) => Ok(Some(token)), - Err(err) => Err(err), - } - }, - Err(io_err) => { - match io_err.kind() { - io::ErrorKind::NotFound => Ok(None), - _ => Err(json::Error::Io(io_err)) - } - } - } - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::Error)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - Io((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty."), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::Io((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}.", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - Io((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::Io((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}.", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type.", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String, Option, Option), - Duplicate(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor.", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character.", field), - FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = - match *suggestion { - Some(ref s) => { - let kv = - match *value { - Some(ref v) => format!("{}={}", s, v), - None => s.clone(), - }; - format!(" Did you mean '{}' ?", kv) - }, - None => String::new(), - }; - writeln!(f, "Field '{}' does not exist.{}", field, suffix) - }, - FieldError::Duplicate(ref cursor) - => writeln!(f, "Value at '{}' was already set", cursor), - FieldError::Empty - => writeln!(f, "Field names must not be empty."), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError(String, String, String, String), - UnknownParameter(String, Vec<&'static str>), - InvalidUploadProtocol(String, Vec), - InvalidKeyValueSyntax(String, bool), - Input(InputError), - Field(FieldError), - MissingCommandError, - MissingMethodError(String), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let suffix = - match did_you_mean(param_name, &possible_values) { - Some(v) => format!(" Did you mean '{}' ?", v), - None => String::new(), - }; - write!(f, "Parameter '{}' is unknown.{}\n", param_name, suffix) - }, - CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { - let hashmap_info = if is_hashmap { "hashmap " } else { "" }; - writeln!(f, "'{}' does not match {}pattern =.", kv, hashmap_info) - }, - CLIError::MissingCommandError => writeln!(f, "Please specify the main sub-command."), - CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the '{}' command.", cmd), - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, - json_console_secret: &str) - -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::Io( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret - = json::from_str(json_console_secret).unwrap(); - match json::to_writer_pretty(&mut f, &console_secret) { - Err(serde_err) => match serde_err { - json::Error::Io(err) => err, - _ => panic!("Unexpected serde error: {:#?}", serde_err) - }, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(f) => { - match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::Io(err)) => - return secret_io_error(err), - Err(json_err) => - return Err(CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::DecoderError( - (secret_str(), json_err) - )))), - Ok(console_secret) => - match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} diff --git a/gen/oauth2_v2-cli/src/main.rs b/gen/oauth2_v2-cli/src/main.rs deleted file mode 100644 index 0546936f71..0000000000 --- a/gen/oauth2_v2-cli/src/main.rs +++ /dev/null @@ -1,542 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -#[macro_use] -extern crate clap; -extern crate yup_oauth2 as oauth2; -extern crate yup_hyper_mock as mock; -extern crate serde; -extern crate serde_json; -extern crate hyper; -extern crate mime; -extern crate strsim; -extern crate google_oauth2_v2 as api; - -use std::env; -use std::io::{self, Write}; -use clap::{App, SubCommand, Arg}; - -mod cmn; - -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol, - calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, FlowType}; -use serde_json as json; -use clap::ArgMatches; - -enum DoitError { - IoError(String, io::Error), - ApiError(api::Error), -} - -struct Engine<'n> { - opt: ArgMatches<'n>, - hub: api::Oauth2>, - gp: Vec<&'static str>, - gpm: Vec<(&'static str, &'static str)>, -} - - -impl<'n> Engine<'n> { - fn _methods_get_cert_for_open_id_connect(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.methods().get_cert_for_open_id_connect(); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _methods_tokeninfo(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.methods().tokeninfo(); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "token-handle" => { - call = call.token_handle(value.unwrap_or("")); - }, - "id-token" => { - call = call.id_token(value.unwrap_or("")); - }, - "access-token" => { - call = call.access_token(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["access-token", "id-token", "token-handle"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _userinfo_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.userinfo().get(); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _userinfo_v2_me_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.userinfo().v2_me_get(); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _doit(&self, dry_run: bool) -> Result, Option> { - let mut err = InvalidOptionsError::new(); - let mut call_result: Result<(), DoitError> = Ok(()); - let mut err_opt: Option = None; - match self.opt.subcommand() { - ("methods", Some(opt)) => { - match opt.subcommand() { - ("get-cert-for-open-id-connect", Some(opt)) => { - call_result = self._methods_get_cert_for_open_id_connect(opt, dry_run, &mut err); - }, - ("tokeninfo", Some(opt)) => { - call_result = self._methods_tokeninfo(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("methods".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - ("userinfo", Some(opt)) => { - match opt.subcommand() { - ("get", Some(opt)) => { - call_result = self._userinfo_get(opt, dry_run, &mut err); - }, - ("v2-me-get", Some(opt)) => { - call_result = self._userinfo_v2_me_get(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("userinfo".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - _ => { - err.issues.push(CLIError::MissingCommandError); - writeln!(io::stderr(), "{}\n", self.opt.usage()).ok(); - } - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - Err(err_opt) - } else { - Ok(call_result) - } - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: ArgMatches<'n>) -> Result, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "oauth2-v2-secret.json", - "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, - if opt.is_present("debug-auth") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }, - JsonTokenStorage { - program_name: "oauth2-v2", - db_dir: config_dir.clone(), - }, Some(FlowType::InstalledRedirect(54324))); - - let client = - if opt.is_present("debug") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }; - let engine = Engine { - opt: opt, - hub: api::Oauth2::new(client, auth), - gp: vec!["alt", "fields", "key", "oauth-token", "pretty-print", "quota-user", "user-ip"], - gpm: vec![ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ] - }; - - match engine._doit(true) { - Err(Some(err)) => Err(err), - Err(None) => Ok(engine), - Ok(_) => unreachable!(), - } - } - - fn doit(&self) -> Result<(), DoitError> { - match self._doit(false) { - Ok(res) => res, - Err(_) => unreachable!(), - } - } -} - -fn main() { - let mut exit_status = 0i32; - let arg_data = [ - ("methods", "methods: 'get-cert-for-open-id-connect' and 'tokeninfo'", vec![ - ("get-cert-for-open-id-connect", - None, - "Details at http://byron.github.io/google-apis-rs/google_oauth2_v2_cli/methods_get-cert-for-open-id-connect", - vec![ - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("tokeninfo", - None, - "Details at http://byron.github.io/google-apis-rs/google_oauth2_v2_cli/methods_tokeninfo", - vec![ - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ("userinfo", "methods: 'get' and 'v2-me-get'", vec![ - ("get", - None, - "Details at http://byron.github.io/google-apis-rs/google_oauth2_v2_cli/userinfo_get", - vec![ - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("v2-me-get", - None, - "Details at http://byron.github.io/google-apis-rs/google_oauth2_v2_cli/userinfo_v2-me-get", - vec![ - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ]; - - let mut app = App::new("oauth2-v2") - .author("Sebastian Thiel ") - .version("0.3.6+20160330") - .about("Obtains end-user authorization grants for use with other Google APIs.") - .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_oauth2_v2_cli") - .arg(Arg::with_name("url") - .long("scope") - .help("Specify the authentication a method should be executed in. Each scope requires the user to grant this application permission to use it.If unset, it defaults to the shortest scope url for a particular method.") - .multiple(true) - .takes_value(true)) - .arg(Arg::with_name("folder") - .long("config-dir") - .help("A directory into which we will store our persistent data. Defaults to a user-writable directory that we will create during the first invocation.[default: ~/.google-service-cli") - .multiple(false) - .takes_value(true)) - .arg(Arg::with_name("debug") - .long("debug") - .help("Output all server communication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)) - .arg(Arg::with_name("debug-auth") - .long("debug-auth") - .help("Output all communication related to authentication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)); - - for &(main_command_name, about, ref subcommands) in arg_data.iter() { - let mut mcmd = SubCommand::with_name(main_command_name).about(about); - - for &(sub_command_name, ref desc, url_info, ref args) in subcommands { - let mut scmd = SubCommand::with_name(sub_command_name); - if let &Some(desc) = desc { - scmd = scmd.about(desc); - } - scmd = scmd.after_help(url_info); - - for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args { - let arg_name_str = - match (arg_name, flag) { - (&Some(an), _ ) => an, - (_ , &Some(f)) => f, - _ => unreachable!(), - }; - let mut arg = Arg::with_name(arg_name_str) - .empty_values(false); - if let &Some(short_flag) = flag { - arg = arg.short(short_flag); - } - if let &Some(desc) = desc { - arg = arg.help(desc); - } - if arg_name.is_some() && flag.is_some() { - arg = arg.takes_value(true); - } - if let &Some(required) = required { - arg = arg.required(required); - } - if let &Some(multi) = multi { - arg = arg.multiple(multi); - } - scmd = scmd.arg(arg); - } - mcmd = mcmd.subcommand(scmd); - } - app = app.subcommand(mcmd); - } - - let matches = app.get_matches(); - - let debug = matches.is_present("debug"); - match Engine::new(matches) { - Err(err) => { - exit_status = err.exit_code; - writeln!(io::stderr(), "{}", err).ok(); - }, - Ok(engine) => { - if let Err(doit_err) = engine.doit() { - exit_status = 1; - match doit_err { - DoitError::IoError(path, err) => { - writeln!(io::stderr(), "Failed to open output file '{}': {}", path, err).ok(); - }, - DoitError::ApiError(err) => { - if debug { - writeln!(io::stderr(), "{:#?}", err).ok(); - } else { - writeln!(io::stderr(), "{}", err).ok(); - } - } - } - } - } - } - - std::process::exit(exit_status); -} \ No newline at end of file diff --git a/gen/oauth2_v2/Cargo.toml b/gen/oauth2_v2/Cargo.toml deleted file mode 100644 index 36d151df94..0000000000 --- a/gen/oauth2_v2/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-oauth2_v2" -version = "0.1.14+20160330" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with oauth2 (protocol v2)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/oauth2_v2" -homepage = "https://developers.google.com/accounts/docs/OAuth2" -documentation = "http://byron.github.io/google-apis-rs/google_oauth2_v2" -license = "MIT" -keywords = ["oauth2", "google", "protocol", "web", "api"] -build = "src/build.rs" - - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -url = "= 0.5" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - diff --git a/gen/oauth2_v2/LICENSE.md b/gen/oauth2_v2/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/oauth2_v2/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/oauth2_v2/README.md b/gen/oauth2_v2/README.md deleted file mode 100644 index 8de90b4a35..0000000000 --- a/gen/oauth2_v2/README.md +++ /dev/null @@ -1,178 +0,0 @@ - -The `google-oauth2_v2` library allows access to all features of the *Google oauth2* service. - -This documentation was generated from *oauth2* crate version *0.1.14+20160330*, where *20160330* is the exact revision of the *oauth2:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. - -Everything else about the *oauth2* *v2* API can be found at the -[official documentation site](https://developers.google.com/accounts/docs/OAuth2). -# Features - -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_oauth2_v2/struct.Oauth2.html) ... - -* userinfo - * [*get*](http://byron.github.io/google-apis-rs/google_oauth2_v2/struct.UserinfoGetCall.html) and [*v2 me get*](http://byron.github.io/google-apis-rs/google_oauth2_v2/struct.UserinfoV2MeGetCall.html) - -Other activities are ... - -* [get cert for open id connect](http://byron.github.io/google-apis-rs/google_oauth2_v2/struct.MethodGetCertForOpenIdConnectCall.html) -* [tokeninfo](http://byron.github.io/google-apis-rs/google_oauth2_v2/struct.MethodTokeninfoCall.html) - - - -# Structure of this Library - -The API is structured into the following primary items: - -* **[Hub](http://byron.github.io/google-apis-rs/google_oauth2_v2/struct.Oauth2.html)** - * a central object to maintain state and allow accessing all *Activities* - * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.MethodsBuilder.html) which in turn - allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.CallBuilder.html) -* **[Resources](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.Resource.html)** - * primary types that you can apply *Activities* to - * a collection of properties and *Parts* - * **[Parts](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.Part.html)** - * a collection of properties - * never directly used in *Activities* -* **[Activities](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.CallBuilder.html)** - * 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() -``` - -Or specifically ... - -```ignore -let r = hub.userinfo().v2_me_get(...).doit() -let r = hub.userinfo().get(...).doit() -``` - -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-oauth2_v2 = "*" -``` - -## A complete example - -```Rust -extern crate hyper; -extern crate yup_oauth2 as oauth2; -extern crate google_oauth2_v2 as oauth2_v2; -use oauth2_v2::{Result, Error}; -use std::default::Default; -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use oauth2_v2::Oauth2; - -// Get an ApplicationSecret instance by some means. It contains the `client_id` and -// `client_secret`, among other things. -let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - ::default(), None); -let mut hub = Oauth2::new(hyper::Client::new(), auth); -// 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.userinfo().v2_me_get() - .doit(); - -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::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](http://byron.github.io/google-apis-rs/google_oauth2_v2/enum.Result.html) enumeration as return value of -the doit() methods, or handed as possibly intermediate results to either the -[Hub Delegate](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_oauth2_v2/../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](http://byron.github.io/google-apis-rs/google_oauth2_v2/enum.Result.html), should be -read by you to obtain the media. -If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.ResponseResult.html), 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](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.Delegate.html) to the -[Method Builder](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.CallBuilder.html) 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](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.Delegate.html) 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 [enocodable](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.RequestValue.html) and -[decodable](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -are valid. -Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.Part.html) 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](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.CallBuilder.html), 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](http://byron.github.io/google-apis-rs/google_oauth2_v2/trait.RequestValue.html) 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 **oauth2_v2** 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-rs/LICENSE.md diff --git a/gen/oauth2_v2/src/build.rs b/gen/oauth2_v2/src/build.rs deleted file mode 100644 index 0bebaf0bf0..0000000000 --- a/gen/oauth2_v2/src/build.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[cfg(feature = "with-serde-codegen")] -mod inner { - extern crate serde_codegen; - - use std::env; - use std::path::Path; - - pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - - let src = Path::new("src/lib.rs.in"); - let dst = Path::new(&out_dir).join("lib.rs"); - - serde_codegen::expand(&src, &dst).unwrap(); - } -} - -#[cfg(not(feature = "with-serde-codegen"))] -mod inner { - pub fn main() {} -} - -pub fn main() { - inner::main() -} \ No newline at end of file diff --git a/gen/oauth2_v2/src/cmn.rs b/gen/oauth2_v2/src/cmn.rs deleted file mode 100644 index d75063e466..0000000000 --- a/gen/oauth2_v2/src/cmn.rs +++ /dev/null @@ -1,753 +0,0 @@ -// COPY OF 'src/rust/api/cmn.rs' -// DO NOT EDIT -use std::io::{self, Read, Seek, Cursor, Write, SeekFrom}; -use std; -use std::fmt::{self, Display}; -use std::str::FromStr; -use std::error; -use std::thread::sleep; -use std::time::Duration; - -use mime::{Mime, TopLevel, SubLevel, Attr, Value}; -use oauth2::{TokenType, Retry, self}; -use hyper; -use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header, - HeaderFormat, Bearer}; -use hyper::http::h1::LINE_ENDING; -use hyper::method::Method; -use hyper::status::StatusCode; - -use serde_json as json; - -/// 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 {} -impl 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 utility type which can decode a server response that indicates error -#[derive(Deserialize)] -pub struct JsonServerError { - pub error: String, - pub error_description: Option -} - -/// A utility to represent detailed errors we might see in case there are BadRequests. -/// The latter happen if the sent parameters or request structures are unsound -#[derive(Deserialize, Serialize, Debug)] -pub struct ErrorResponse { - error: ServerError, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerError { - errors: Vec, - code: u16, - message: String, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerMessage { - domain: String, - reason: String, - message: String, - #[serde(rename="locationType")] - location_type: Option, - location: Option -} - -#[derive(Copy, Clone)] -pub struct DummyNetworkStream; - -impl Read for DummyNetworkStream { - fn read(&mut self, _: &mut [u8]) -> io::Result { - Ok(0) - } -} - -impl Write for DummyNetworkStream { - fn write(&mut self, _: &[u8]) -> io::Result { - Ok(0) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl hyper::net::NetworkStream for DummyNetworkStream { - fn peer_addr(&mut self) -> io::Result { - Ok("127.0.0.1:1337".parse().unwrap()) - } - - fn set_read_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } - - fn set_write_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } -} - - -/// 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 { - - /// 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, MethodInfo) {} - - /// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), 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, &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 { - 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: &error::Error) -> Option { - 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 { - 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::client::Response, Option, _: Option) -> 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(ErrorResponse), - - /// 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(Box), - - /// 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::client::Response), -} - - -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - 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 err) => { - try!(writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message)); - for err in err.error.errors.iter() { - try!(writeln!(f, " {}: {}, {}{}", - err.domain, - err.message, - err.reason, - match &err.location { - &Some(ref loc) => format!("@{}", loc), - &None => String::new(), - })); - } - 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 description(&self) -> &str { - match *self { - Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(_, ref err) => err.description(), - _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" - } - } - - fn cause(&self) -> Option<&error::Error> { - match *self { - Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(_, ref err) => err.cause(), - _ => None - } - } -} - -/// A universal result type used as return for all calls. -pub type Result = std::result::Result; - -/// Contains information about an API request. -pub struct MethodInfo { - pub id: &'static str, - pub http_method: Method, -} - -const BOUNDARY: &'static 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<(Headers, &'a mut Read)>, - current_part: Option<(Cursor>, &'a mut Read)>, - last_part_boundary: Option>>, -} - -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 Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> { - let mut headers = Headers::new(); - headers.set(ContentType(mime_type)); - headers.set(ContentLength(size)); - 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.len() == 0 && 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.len() == 0 && self.current_part.is_some() - } -} - -impl<'a> Read for MultiPartReader<'a> { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - 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::::new()); - (write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING, - headers, 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).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<'a>(&'a self) -> &'a Mime { &self.0 } -} -impl ::std::ops::DerefMut for XUploadContentType { - fn deref_mut<'a>(&'a mut self) -> &'a mut Mime { &mut self.0 } -} -impl Header for XUploadContentType { - fn header_name() -> &'static str { "X-Upload-Content-Type" } - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - hyper::header::parsing::from_one_raw_str(raw).map(XUploadContentType) - } -} -impl HeaderFormat for XUploadContentType { - fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&**self, f) - } -} -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 { - 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, - pub total_length: u64, -} - -impl Header for ContentRange { - fn header_name() -> &'static str { - "Content-Range" - } - - /// We are not parsable, as parsing is done by the `Range` header - fn parse_header(_: &[Vec]) -> hyper::error::Result { - Err(hyper::error::Error::Method) - } -} - - -impl HeaderFormat for ContentRange { - fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes ")); - match self.range { - Some(ref c) => try!(c.fmt(fmt)), - None => try!(fmt.write_str("*")) - } - (write!(fmt, "/{}", self.total_length)).ok(); - Ok(()) - } -} - -#[derive(Clone, PartialEq, Debug)] -pub struct RangeResponseHeader(pub Chunk); - -impl Header for RangeResponseHeader { - fn header_name() -> &'static str { - "Range" - } - - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - if raw.len() > 0 { - let v = &raw[0]; - if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes "; - if s.starts_with(PREFIX) { - if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { - return Ok(RangeResponseHeader(c)) - } - } - } - } - Err(hyper::error::Error::Method) - } -} - -impl HeaderFormat for RangeResponseHeader { - /// No implmentation necessary, we just need to parse - fn fmt_header(&self, _: &mut fmt::Formatter) -> fmt::Result { - Err(fmt::Error) - } -} - -/// A utility type to perform a resumable upload from start to end. -pub struct ResumableUploadHelper<'a, A: 'a> { - pub client: &'a mut hyper::client::Client, - pub delegate: &'a mut Delegate, - pub start_at: Option, - pub auth: &'a mut A, - pub user_agent: &'a str, - pub auth_header: Authorization, - pub url: &'a str, - pub reader: &'a mut ReadSeek, - pub media_type: Mime, - pub content_length: u64 -} - -impl<'a, A> ResumableUploadHelper<'a, A> - where A: oauth2::GetToken { - - fn query_transfer_status(&mut self) -> std::result::Result> { - loop { - match self.client.post(self.url) - .header(UserAgent(self.user_agent.to_string())) - .header(ContentRange { range: None, total_length: self.content_length }) - .header(self.auth_header.clone()) - .send() { - Ok(r) => { - // 308 = resume-incomplete == PermanentRedirect - let headers = r.headers.clone(); - let h: &RangeResponseHeader = match headers.get() { - Some(hh) if r.status == StatusCode::PermanentRedirect => hh, - None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None, 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 fn upload(&mut self) -> Option> { - let mut start = match self.start_at { - Some(s) => s, - None => match self.query_transfer_status() { - 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 - }; - - self.reader.seek(SeekFrom::Start(start)).unwrap(); - loop { - 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 range_header = ContentRange { - range: Some(Chunk {first: start, last: start + request_size - 1}), - total_length: self.content_length - }; - start += request_size; - if self.delegate.cancel_chunk_upload(&range_header) { - return None - } - let res = self.client.post(self.url) - .header(range_header) - .header(ContentType(self.media_type.clone())) - .header(UserAgent(self.user_agent.to_string())) - .body(&mut section_reader) - .send(); - match res { - Ok(mut res) => { - if res.status == StatusCode::PermanentRedirect { - continue - } - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - } - return Some(Ok(res)) - }, - Err(err) => { - if let Retry::After(d) = self.delegate.http_error(&err) { - sleep(d); - continue; - } - return Some(Err(err)) - } - } - } - } -} - -// Copy of src/rust/cli/cmn.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); - } - } - _ => {} - } -} diff --git a/gen/oauth2_v2/src/lib.rs b/gen/oauth2_v2/src/lib.rs deleted file mode 100644 index 1ec59a0dce..0000000000 --- a/gen/oauth2_v2/src/lib.rs +++ /dev/null @@ -1,188 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.mako' -// DO NOT EDIT ! - -//! This documentation was generated from *oauth2* crate version *0.1.14+20160330*, where *20160330* is the exact revision of the *oauth2:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. -//! -//! Everything else about the *oauth2* *v2* API can be found at the -//! [official documentation site](https://developers.google.com/accounts/docs/OAuth2). -//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/oauth2_v2). -//! # Features -//! -//! Handle the following *Resources* with ease from the central [hub](struct.Oauth2.html) ... -//! -//! * userinfo -//! * [*get*](struct.UserinfoGetCall.html) and [*v2 me get*](struct.UserinfoV2MeGetCall.html) -//! -//! Other activities are ... -//! -//! * [get cert for open id connect](struct.MethodGetCertForOpenIdConnectCall.html) -//! * [tokeninfo](struct.MethodTokeninfoCall.html) -//! -//! -//! -//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html). -//! -//! # Structure of this Library -//! -//! The API is structured into the following primary items: -//! -//! * **[Hub](struct.Oauth2.html)** -//! * a central object to maintain state and allow accessing all *Activities* -//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn -//! allow access to individual [*Call Builders*](trait.CallBuilder.html) -//! * **[Resources](trait.Resource.html)** -//! * primary types that you can apply *Activities* to -//! * a collection of properties and *Parts* -//! * **[Parts](trait.Part.html)** -//! * a collection of properties -//! * never directly used in *Activities* -//! * **[Activities](trait.CallBuilder.html)** -//! * 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() -//! ``` -//! -//! Or specifically ... -//! -//! ```ignore -//! let r = hub.userinfo().v2_me_get(...).doit() -//! let r = hub.userinfo().get(...).doit() -//! ``` -//! -//! 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-oauth2_v2 = "*" -//! ``` -//! -//! ## A complete example -//! -//! ```test_harness,no_run -//! extern crate hyper; -//! extern crate yup_oauth2 as oauth2; -//! extern crate google_oauth2_v2 as oauth2_v2; -//! use oauth2_v2::{Result, Error}; -//! # #[test] fn egal() { -//! use std::default::Default; -//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use oauth2_v2::Oauth2; -//! -//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and -//! // `client_secret`, among other things. -//! let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -//! hyper::Client::new(), -//! ::default(), None); -//! let mut hub = Oauth2::new(hyper::Client::new(), auth); -//! // 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.userinfo().v2_me_get() -//! .doit(); -//! -//! 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::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](enum.Result.html) enumeration as return value of -//! the doit() methods, or handed as possibly intermediate results to either the -//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../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](enum.Result.html), should be -//! read by you to obtain the media. -//! If such a method also supports a [Response Result](trait.ResponseResult.html), 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](trait.Delegate.html) to the -//! [Method Builder](trait.CallBuilder.html) 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](trait.Delegate.html) 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 [enocodable](trait.RequestValue.html) and -//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -//! are valid. -//! Most optionals are are considered [Parts](trait.Part.html) 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](trait.CallBuilder.html), 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](trait.RequestValue.html) 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 ... . -#![cfg_attr(feature = "nightly", feature(custom_derive, custom_attribute, plugin))] -#![cfg_attr(feature = "nightly", plugin(serde_macros))] -#![allow(unused_imports, unused_mut, dead_code)] - -#[cfg(feature = "nightly")] -include!("lib.rs.in"); - -#[cfg(feature = "with-serde-codegen")] -include!(concat!(env!("OUT_DIR"), "/lib.rs")); \ No newline at end of file diff --git a/gen/oauth2_v2/src/lib.rs.in b/gen/oauth2_v2/src/lib.rs.in deleted file mode 100644 index f5e2821851..0000000000 --- a/gen/oauth2_v2/src/lib.rs.in +++ /dev/null @@ -1,1202 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.in.mako' -// DO NOT EDIT ! - -extern crate hyper; -extern crate serde; -extern crate serde_json; -extern crate yup_oauth2 as oauth2; -extern crate mime; -extern crate url; - -mod cmn; - -use std::collections::HashMap; -use std::cell::RefCell; -use std::borrow::BorrowMut; -use std::default::Default; -use std::collections::BTreeMap; -use serde_json as json; -use std::io; -use std::fs; -use std::thread::sleep; -use std::time::Duration; - -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, - ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, - Resource, ErrorResponse, remove_json_null_values}; - - -// ############## -// UTILITIES ### -// ############ - -/// Identifies the an OAuth2 authorization scope. -/// A scope is needed when requesting an -/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). -#[derive(PartialEq, Eq, Hash)] -pub enum Scope { - /// Know the list of people in your circles, your age range, and language - PluLogin, - - /// View your email address - UserinfoEmail, - - /// View your basic profile info - UserinfoProfile, - - /// Know who you are on Google - PluMe, -} - -impl AsRef for Scope { - fn as_ref(&self) -> &str { - match *self { - Scope::PluLogin => "https://www.googleapis.com/auth/plus.login", - Scope::UserinfoEmail => "https://www.googleapis.com/auth/userinfo.email", - Scope::UserinfoProfile => "https://www.googleapis.com/auth/userinfo.profile", - Scope::PluMe => "https://www.googleapis.com/auth/plus.me", - } - } -} - -impl Default for Scope { - fn default() -> Scope { - Scope::PluMe - } -} - - - -// ######## -// HUB ### -// ###### - -/// Central instance to access all Oauth2 related resource activities -/// -/// # Examples -/// -/// Instantiate a new hub -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_oauth2_v2 as oauth2_v2; -/// use oauth2_v2::{Result, Error}; -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use oauth2_v2::Oauth2; -/// -/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and -/// // `client_secret`, among other things. -/// let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Oauth2::new(hyper::Client::new(), auth); -/// // 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.userinfo().v2_me_get() -/// .doit(); -/// -/// 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::MissingAPIKey -/// |Error::MissingToken(_) -/// |Error::Cancelled -/// |Error::UploadSizeLimitExceeded(_, _) -/// |Error::Failure(_) -/// |Error::BadRequest(_) -/// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_, _) => println!("{}", e), -/// }, -/// Ok(res) => println!("Success: {:?}", res), -/// } -/// # } -/// ``` -pub struct Oauth2 { - client: RefCell, - auth: RefCell, - _user_agent: String, -} - -impl<'a, C, A> Hub for Oauth2 {} - -impl<'a, C, A> Oauth2 - where C: BorrowMut, A: oauth2::GetToken { - - pub fn new(client: C, authenticator: A) -> Oauth2 { - Oauth2 { - client: RefCell::new(client), - auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.14".to_string(), - } - } - - pub fn methods(&'a self) -> MethodMethods<'a, C, A> { - MethodMethods { hub: &self } - } - pub fn userinfo(&'a self) -> UserinfoMethods<'a, C, A> { - UserinfoMethods { hub: &self } - } - - /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.14`. - /// - /// Returns the previously set user-agent. - pub fn user_agent(&mut self, agent_name: String) -> String { - let prev = self._user_agent.clone(); - self._user_agent = agent_name; - prev - } -} - - -// ############ -// SCHEMAS ### -// ########## -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct JwkKeys { - /// no description provided - #[serde(rename="use")] - pub use_: Option, - /// no description provided - pub e: Option, - /// no description provided - pub kty: Option, - /// no description provided - pub alg: Option, - /// no description provided - pub kid: Option, - /// no description provided - pub n: Option, -} - -impl NestedType for JwkKeys {} -impl Part for JwkKeys {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get cert for open id connect](struct.MethodGetCertForOpenIdConnectCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Jwk { - /// no description provided - pub keys: Option>, -} - -impl ResponseResult for Jwk {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [v2 me get userinfo](struct.UserinfoV2MeGetCall.html) (response) -/// * [get userinfo](struct.UserinfoGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Userinfoplus { - /// The user's last name. - pub family_name: Option, - /// The user's full name. - pub name: Option, - /// URL of the user's picture image. - pub picture: Option, - /// The user's preferred locale. - pub locale: Option, - /// The user's gender. - pub gender: Option, - /// The obfuscated ID of the user. - pub id: Option, - /// URL of the profile page. - pub link: Option, - /// The user's first name. - pub given_name: Option, - /// The user's email address. - pub email: Option, - /// The hosted domain e.g. example.com if the user is Google apps user. - pub hd: Option, - /// Boolean flag which is true if the email address is verified. Always verified because we only return the user's primary email address. - pub verified_email: Option, -} - -impl ResponseResult for Userinfoplus {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [tokeninfo](struct.MethodTokeninfoCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Tokeninfo { - /// To whom was the token issued to. In general the same as audience. - pub issued_to: Option, - /// The token handle associated with this token. - pub token_handle: Option, - /// The expiry time of the token, as number of seconds left until expiry. - pub expires_in: Option, - /// The access type granted with this token. It can be offline or online. - pub access_type: Option, - /// Who is the intended audience for this token. In general the same as issued_to. - pub audience: Option, - /// The space separated list of scopes granted to this token. - pub scope: Option, - /// The obfuscated user id. - pub user_id: Option, - /// The email address of the user. Present only if the email scope is present in the request. - pub email: Option, - /// Boolean flag which is true if the email address is verified. Present only if the email scope is present in the request. - pub verified_email: Option, -} - -impl ResponseResult for Tokeninfo {} - - - -// ################### -// MethodBuilders ### -// ################# - -/// A builder providing access to all methods supported on *userinfo* resources. -/// It is not used directly, but through the `Oauth2` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_oauth2_v2 as oauth2_v2; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use oauth2_v2::Oauth2; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Oauth2::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)` and `v2_me_get(...)` -/// // to build up your call. -/// let rb = hub.userinfo(); -/// # } -/// ``` -pub struct UserinfoMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Oauth2, -} - -impl<'a, C, A> MethodsBuilder for UserinfoMethods<'a, C, A> {} - -impl<'a, C, A> UserinfoMethods<'a, C, A> { - - pub fn v2_me_get(&self) -> UserinfoV2MeGetCall<'a, C, A> { - UserinfoV2MeGetCall { - hub: self.hub, - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - pub fn get(&self) -> UserinfoGetCall<'a, C, A> { - UserinfoGetCall { - hub: self.hub, - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all free methods, which are not associated with a particular resource. -/// It is not used directly, but through the `Oauth2` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_oauth2_v2 as oauth2_v2; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use oauth2_v2::Oauth2; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Oauth2::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get_cert_for_open_id_connect(...)` and `tokeninfo(...)` -/// // to build up your call. -/// let rb = hub.methods(); -/// # } -/// ``` -pub struct MethodMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Oauth2, -} - -impl<'a, C, A> MethodsBuilder for MethodMethods<'a, C, A> {} - -impl<'a, C, A> MethodMethods<'a, C, A> { - - pub fn tokeninfo(&self) -> MethodTokeninfoCall<'a, C, A> { - MethodTokeninfoCall { - hub: self.hub, - _token_handle: Default::default(), - _id_token: Default::default(), - _access_token: Default::default(), - _delegate: Default::default(), - _additional_params: Default::default(), - } - } - - pub fn get_cert_for_open_id_connect(&self) -> MethodGetCertForOpenIdConnectCall<'a, C, A> { - MethodGetCertForOpenIdConnectCall { - hub: self.hub, - _delegate: Default::default(), - _additional_params: Default::default(), - } - } -} - - - - - -// ################### -// CallBuilders ### -// ################# - -/// A builder for the *v2.me.get* method supported by a *userinfo* resource. -/// It is not used directly, but through a `UserinfoMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_oauth2_v2 as oauth2_v2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use oauth2_v2::Oauth2; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Oauth2::new(hyper::Client::new(), auth); -/// // 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.userinfo().v2_me_get() -/// .doit(); -/// # } -/// ``` -pub struct UserinfoV2MeGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Oauth2, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UserinfoV2MeGetCall<'a, C, A> {} - -impl<'a, C, A> UserinfoV2MeGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Userinfoplus)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "oauth2.userinfo.v2.me.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); - for &field in ["alt"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/userinfo/v2/me".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::PluLogin.as_ref().to_string(), ()); - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserinfoV2MeGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> UserinfoV2MeGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::PluLogin`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> UserinfoV2MeGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// A builder for the *get* method supported by a *userinfo* resource. -/// It is not used directly, but through a `UserinfoMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_oauth2_v2 as oauth2_v2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use oauth2_v2::Oauth2; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Oauth2::new(hyper::Client::new(), auth); -/// // 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.userinfo().get() -/// .doit(); -/// # } -/// ``` -pub struct UserinfoGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Oauth2, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UserinfoGetCall<'a, C, A> {} - -impl<'a, C, A> UserinfoGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Userinfoplus)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "oauth2.userinfo.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); - for &field in ["alt"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/oauth2/v2/userinfo".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::PluLogin.as_ref().to_string(), ()); - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserinfoGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> UserinfoGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::PluLogin`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> UserinfoGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// A builder for the *tokeninfo* method. -/// It is not used directly, but through a `MethodMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_oauth2_v2 as oauth2_v2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use oauth2_v2::Oauth2; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Oauth2::new(hyper::Client::new(), auth); -/// // 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.methods().tokeninfo() -/// .token_handle("eirmod") -/// .id_token("sit") -/// .access_token("Stet") -/// .doit(); -/// # } -/// ``` -pub struct MethodTokeninfoCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Oauth2, - _token_handle: Option, - _id_token: Option, - _access_token: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, -} - -impl<'a, C, A> CallBuilder for MethodTokeninfoCall<'a, C, A> {} - -impl<'a, C, A> MethodTokeninfoCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Tokeninfo)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "oauth2.tokeninfo", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - if let Some(value) = self._token_handle { - params.push(("token_handle", value.to_string())); - } - if let Some(value) = self._id_token { - params.push(("id_token", value.to_string())); - } - if let Some(value) = self._access_token { - params.push(("access_token", value.to_string())); - } - for &field in ["alt", "token_handle", "id_token", "access_token"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/oauth2/v2/tokeninfo".to_string(); - - let mut key = self.hub.auth.borrow_mut().api_key(); - if key.is_none() { - key = dlg.api_key(); - } - match key { - Some(value) => params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *token_handle* query property to the given value. - pub fn token_handle(mut self, new_value: &str) -> MethodTokeninfoCall<'a, C, A> { - self._token_handle = Some(new_value.to_string()); - self - } - /// - /// Sets the *id_token* query property to the given value. - pub fn id_token(mut self, new_value: &str) -> MethodTokeninfoCall<'a, C, A> { - self._id_token = Some(new_value.to_string()); - self - } - /// - /// Sets the *access_token* query property to the given value. - pub fn access_token(mut self, new_value: &str) -> MethodTokeninfoCall<'a, C, A> { - self._access_token = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> MethodTokeninfoCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> MethodTokeninfoCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - -} - - -/// A builder for the *getCertForOpenIdConnect* method. -/// It is not used directly, but through a `MethodMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_oauth2_v2 as oauth2_v2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use oauth2_v2::Oauth2; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Oauth2::new(hyper::Client::new(), auth); -/// // 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.methods().get_cert_for_open_id_connect() -/// .doit(); -/// # } -/// ``` -pub struct MethodGetCertForOpenIdConnectCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Oauth2, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, -} - -impl<'a, C, A> CallBuilder for MethodGetCertForOpenIdConnectCall<'a, C, A> {} - -impl<'a, C, A> MethodGetCertForOpenIdConnectCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Jwk)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "oauth2.getCertForOpenIdConnect", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); - for &field in ["alt"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/oauth2/v2/certs".to_string(); - - let mut key = self.hub.auth.borrow_mut().api_key(); - if key.is_none() { - key = dlg.api_key(); - } - match key { - Some(value) => params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> MethodGetCertForOpenIdConnectCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> MethodGetCertForOpenIdConnectCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - -} - - diff --git a/gen/pagespeedonline2-cli/Cargo.toml b/gen/pagespeedonline2-cli/Cargo.toml index f390601c6f..d26d79aead 100644 --- a/gen/pagespeedonline2-cli/Cargo.toml +++ b/gen/pagespeedonline2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-pagespeedonline2-cli" -version = "0.3.6+20160811" +version = "1.0.0+20160811" authors = ["Sebastian Thiel "] description = "A complete library to interact with pagespeedonline (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/pagespeedonline2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-pagespeedonline2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-pagespeedonline2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-pagespeedonline2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-pagespeedonline2] path = "../pagespeedonline2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/pagespeedonline2-cli/README.md b/gen/pagespeedonline2-cli/README.md index 17d45a3905..8f83087fb8 100644 --- a/gen/pagespeedonline2-cli/README.md +++ b/gen/pagespeedonline2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *pagespeedonline* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/pagespeedonline2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/pagespeedonline2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/pagespeedonline2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/pagespeedonline2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/pagespeedonline2-cli). # Usage -This documentation was generated from the *pagespeedonline* API at revision *20160811*. The CLI is at version *0.3.6*. +This documentation was generated from the *pagespeedonline* API at revision *20160811*. The CLI is at version *1.0.0*. ```bash pagespeedonline2 [options] diff --git a/gen/pagespeedonline2-cli/mkdocs.yml b/gen/pagespeedonline2-cli/mkdocs.yml index bf544ebe99..65d9de54d1 100644 --- a/gen/pagespeedonline2-cli/mkdocs.yml +++ b/gen/pagespeedonline2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: pagespeedonline v0.3.6+20160811 +site_name: pagespeedonline v1.0.0+20160811 site_url: http://byron.github.io/google-apis-rs/google-pagespeedonline2-cli site_description: Write integrating applications with bcore diff --git a/gen/pagespeedonline2-cli/src/main.rs b/gen/pagespeedonline2-cli/src/main.rs index 5cad0c244e..6806d9054c 100644 --- a/gen/pagespeedonline2-cli/src/main.rs +++ b/gen/pagespeedonline2-cli/src/main.rs @@ -237,7 +237,7 @@ fn main() { let mut app = App::new("pagespeedonline2") .author("Sebastian Thiel ") - .version("0.3.6+20160811") + .version("1.0.0+20160811") .about("Analyzes the performance of a web page and provides tailored suggestions to make that page faster.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_pagespeedonline2_cli") .arg(Arg::with_name("folder") diff --git a/gen/partners2-cli/Cargo.toml b/gen/partners2-cli/Cargo.toml index 16d41e210c..f4414907a6 100644 --- a/gen/partners2-cli/Cargo.toml +++ b/gen/partners2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-partners2-cli" -version = "0.3.6+20151009" +version = "1.0.0+20151009" authors = ["Sebastian Thiel "] description = "A complete library to interact with partners (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/partners2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-partners2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-partners2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-partners2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-partners2] path = "../partners2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/partners2-cli/README.md b/gen/partners2-cli/README.md index f8548ecc15..03405e7c7d 100644 --- a/gen/partners2-cli/README.md +++ b/gen/partners2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *partners* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/partners2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/partners2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/partners2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/partners2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/partners2-cli). # Usage -This documentation was generated from the *partners* API at revision *20151009*. The CLI is at version *0.3.6*. +This documentation was generated from the *partners* API at revision *20151009*. The CLI is at version *1.0.0*. ```bash partners2 [options] diff --git a/gen/partners2-cli/mkdocs.yml b/gen/partners2-cli/mkdocs.yml index 940536d1b2..23f430f3db 100644 --- a/gen/partners2-cli/mkdocs.yml +++ b/gen/partners2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: partners v0.3.6+20151009 +site_name: partners v1.0.0+20151009 site_url: http://byron.github.io/google-apis-rs/google-partners2-cli site_description: Write integrating applications with bcore diff --git a/gen/partners2-cli/src/main.rs b/gen/partners2-cli/src/main.rs index 1c6683d104..1b3cb72799 100644 --- a/gen/partners2-cli/src/main.rs +++ b/gen/partners2-cli/src/main.rs @@ -901,7 +901,7 @@ fn main() { let mut app = App::new("partners2") .author("Sebastian Thiel ") - .version("0.3.6+20151009") + .version("1.0.0+20151009") .about("Lets advertisers search certified companies and create contact leads with them, and also audits the usage of clients.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_partners2_cli") .arg(Arg::with_name("folder") diff --git a/gen/people1-cli/Cargo.toml b/gen/people1-cli/Cargo.toml index 98874401a7..c2997e6118 100644 --- a/gen/people1-cli/Cargo.toml +++ b/gen/people1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-people1-cli" -version = "0.3.6+20160210" +version = "1.0.0+20160210" authors = ["Sebastian Thiel "] description = "A complete library to interact with people (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/people1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-people1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-people1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-people1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-people1] path = "../people1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/people1-cli/README.md b/gen/people1-cli/README.md index b704f8b111..144629fd7f 100644 --- a/gen/people1-cli/README.md +++ b/gen/people1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *people* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/people1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/people1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/people1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/people1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/people1-cli). # Usage -This documentation was generated from the *people* API at revision *20160210*. The CLI is at version *0.3.6*. +This documentation was generated from the *people* API at revision *20160210*. The CLI is at version *1.0.0*. ```bash people1 [options] diff --git a/gen/people1-cli/mkdocs.yml b/gen/people1-cli/mkdocs.yml index de0bc684b2..3f0371a3a4 100644 --- a/gen/people1-cli/mkdocs.yml +++ b/gen/people1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: people v0.3.6+20160210 +site_name: people v1.0.0+20160210 site_url: http://byron.github.io/google-apis-rs/google-people1-cli site_description: Write integrating applications with bcore diff --git a/gen/people1-cli/src/main.rs b/gen/people1-cli/src/main.rs index 61097d5228..18407fbd13 100644 --- a/gen/people1-cli/src/main.rs +++ b/gen/people1-cli/src/main.rs @@ -403,7 +403,7 @@ fn main() { let mut app = App::new("people1") .author("Sebastian Thiel ") - .version("0.3.6+20160210") + .version("1.0.0+20160210") .about("The Google People API service gives access to information about profiles and contacts.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_people1_cli") .arg(Arg::with_name("url") diff --git a/gen/playmoviespartner1-cli/Cargo.toml b/gen/playmoviespartner1-cli/Cargo.toml index d3b5aa247a..74c22f71ab 100644 --- a/gen/playmoviespartner1-cli/Cargo.toml +++ b/gen/playmoviespartner1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-playmoviespartner1-cli" -version = "0.3.6+20160518" +version = "1.0.0+20160518" authors = ["Sebastian Thiel "] description = "A complete library to interact with Play Movies (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/playmoviespartner1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-playmoviespartner1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-playmoviespartner1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-playmoviespartner1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-playmoviespartner1] path = "../playmoviespartner1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/playmoviespartner1-cli/README.md b/gen/playmoviespartner1-cli/README.md index 29e2a1947b..933e271156 100644 --- a/gen/playmoviespartner1-cli/README.md +++ b/gen/playmoviespartner1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Play Movies* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/playmoviespartner1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/playmoviespartner1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/playmoviespartner1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/playmoviespartner1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/playmoviespartner1-cli). # Usage -This documentation was generated from the *Play Movies* API at revision *20160518*. The CLI is at version *0.3.6*. +This documentation was generated from the *Play Movies* API at revision *20160518*. The CLI is at version *1.0.0*. ```bash playmoviespartner1 [options] diff --git a/gen/playmoviespartner1-cli/mkdocs.yml b/gen/playmoviespartner1-cli/mkdocs.yml index 0deafa9b8a..b9367f6e96 100644 --- a/gen/playmoviespartner1-cli/mkdocs.yml +++ b/gen/playmoviespartner1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Play Movies v0.3.6+20160518 +site_name: Play Movies v1.0.0+20160518 site_url: http://byron.github.io/google-apis-rs/google-playmoviespartner1-cli site_description: Write integrating applications with bcore diff --git a/gen/playmoviespartner1-cli/src/main.rs b/gen/playmoviespartner1-cli/src/main.rs index fe100832b0..840232f52e 100644 --- a/gen/playmoviespartner1-cli/src/main.rs +++ b/gen/playmoviespartner1-cli/src/main.rs @@ -1118,7 +1118,7 @@ fn main() { let mut app = App::new("playmoviespartner1") .author("Sebastian Thiel ") - .version("0.3.6+20160518") + .version("1.0.0+20160518") .about("Gets the delivery status of titles for Google Play Movies Partners.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_playmoviespartner1_cli") .arg(Arg::with_name("url") diff --git a/gen/plus1-cli/Cargo.toml b/gen/plus1-cli/Cargo.toml index 3c9b71a5f8..2f3e784146 100644 --- a/gen/plus1-cli/Cargo.toml +++ b/gen/plus1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-plus1-cli" -version = "0.3.6+20160907" +version = "1.0.0+20160907" authors = ["Sebastian Thiel "] description = "A complete library to interact with plus (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/plus1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-plus1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-plus1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-plus1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-plus1] path = "../plus1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/plus1-cli/README.md b/gen/plus1-cli/README.md index 92145f5de5..10ba76290d 100644 --- a/gen/plus1-cli/README.md +++ b/gen/plus1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *plus* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/plus1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/plus1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/plus1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/plus1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/plus1-cli). # Usage -This documentation was generated from the *plus* API at revision *20160907*. The CLI is at version *0.3.6*. +This documentation was generated from the *plus* API at revision *20160907*. The CLI is at version *1.0.0*. ```bash plus1 [options] diff --git a/gen/plus1-cli/mkdocs.yml b/gen/plus1-cli/mkdocs.yml index d7b48bbcee..22f5ee8fec 100644 --- a/gen/plus1-cli/mkdocs.yml +++ b/gen/plus1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: plus v0.3.6+20160907 +site_name: plus v1.0.0+20160907 site_url: http://byron.github.io/google-apis-rs/google-plus1-cli site_description: Write integrating applications with bcore diff --git a/gen/plus1-cli/src/main.rs b/gen/plus1-cli/src/main.rs index e5208183dc..79e27760d3 100644 --- a/gen/plus1-cli/src/main.rs +++ b/gen/plus1-cli/src/main.rs @@ -937,7 +937,7 @@ fn main() { let mut app = App::new("plus1") .author("Sebastian Thiel ") - .version("0.3.6+20160907") + .version("1.0.0+20160907") .about("Builds on top of the Google+ platform.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_plus1_cli") .arg(Arg::with_name("url") diff --git a/gen/plusdomains1-cli/Cargo.toml b/gen/plusdomains1-cli/Cargo.toml index 9ead124423..856ae9f793 100644 --- a/gen/plusdomains1-cli/Cargo.toml +++ b/gen/plusdomains1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-plusdomains1-cli" -version = "0.3.6+20160907" +version = "1.0.0+20160907" authors = ["Sebastian Thiel "] description = "A complete library to interact with plusDomains (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/plusdomains1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-plusdomains1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-plusdomains1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-plusdomains1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-plusdomains1] path = "../plusdomains1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/plusdomains1-cli/README.md b/gen/plusdomains1-cli/README.md index 56fa01babf..98e64e56b8 100644 --- a/gen/plusdomains1-cli/README.md +++ b/gen/plusdomains1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *plusDomains* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/plusdomains1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/plusdomains1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/plusdomains1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/plusdomains1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/plusdomains1-cli). # Usage -This documentation was generated from the *plusDomains* API at revision *20160907*. The CLI is at version *0.3.6*. +This documentation was generated from the *plusDomains* API at revision *20160907*. The CLI is at version *1.0.0*. ```bash plusdomains1 [options] diff --git a/gen/plusdomains1-cli/mkdocs.yml b/gen/plusdomains1-cli/mkdocs.yml index aa21f7c54d..da13356bf3 100644 --- a/gen/plusdomains1-cli/mkdocs.yml +++ b/gen/plusdomains1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: plusDomains v0.3.6+20160907 +site_name: plusDomains v1.0.0+20160907 site_url: http://byron.github.io/google-apis-rs/google-plusdomains1-cli site_description: Write integrating applications with bcore diff --git a/gen/plusdomains1-cli/src/main.rs b/gen/plusdomains1-cli/src/main.rs index 351df09d46..a738d81fb4 100644 --- a/gen/plusdomains1-cli/src/main.rs +++ b/gen/plusdomains1-cli/src/main.rs @@ -2163,7 +2163,7 @@ fn main() { let mut app = App::new("plusdomains1") .author("Sebastian Thiel ") - .version("0.3.6+20160907") + .version("1.0.0+20160907") .about("Builds on top of the Google+ platform for Google Apps Domains.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_plusdomains1_cli") .arg(Arg::with_name("url") diff --git a/gen/prediction1d6-cli/Cargo.toml b/gen/prediction1d6-cli/Cargo.toml index 90c59d6c26..36c5ed7bf3 100644 --- a/gen/prediction1d6-cli/Cargo.toml +++ b/gen/prediction1d6-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-prediction1d6-cli" -version = "0.3.6+20160511" +version = "1.0.0+20160511" authors = ["Sebastian Thiel "] description = "A complete library to interact with prediction (protocol v1.6)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/prediction1d6-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-prediction1d6/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-prediction1d6/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-prediction1d6/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-prediction1d6] path = "../prediction1d6" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/prediction1d6-cli/README.md b/gen/prediction1d6-cli/README.md index a0a42acad5..18cf37193a 100644 --- a/gen/prediction1d6-cli/README.md +++ b/gen/prediction1d6-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *prediction* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/prediction1d6.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/prediction1d6.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/prediction1d6.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/prediction1d6.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/prediction1d6-cli). # Usage -This documentation was generated from the *prediction* API at revision *20160511*. The CLI is at version *0.3.6*. +This documentation was generated from the *prediction* API at revision *20160511*. The CLI is at version *1.0.0*. ```bash prediction1d6 [options] diff --git a/gen/prediction1d6-cli/mkdocs.yml b/gen/prediction1d6-cli/mkdocs.yml index cafd677e26..4ff0de5a55 100644 --- a/gen/prediction1d6-cli/mkdocs.yml +++ b/gen/prediction1d6-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: prediction v0.3.6+20160511 +site_name: prediction v1.0.0+20160511 site_url: http://byron.github.io/google-apis-rs/google-prediction1d6-cli site_description: Write integrating applications with bcore diff --git a/gen/prediction1d6-cli/src/main.rs b/gen/prediction1d6-cli/src/main.rs index dfe78b5bac..be781b6c56 100644 --- a/gen/prediction1d6-cli/src/main.rs +++ b/gen/prediction1d6-cli/src/main.rs @@ -962,7 +962,7 @@ fn main() { let mut app = App::new("prediction1d6") .author("Sebastian Thiel ") - .version("0.3.6+20160511") + .version("1.0.0+20160511") .about("Lets you access a cloud hosted machine learning service that makes it easy to build smart apps") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_prediction1d6_cli") .arg(Arg::with_name("url") diff --git a/gen/proximitybeacon1_beta1-cli/Cargo.toml b/gen/proximitybeacon1_beta1-cli/Cargo.toml index b7d98e572a..305a4cfdd8 100644 --- a/gen/proximitybeacon1_beta1-cli/Cargo.toml +++ b/gen/proximitybeacon1_beta1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-proximitybeacon1_beta1-cli" -version = "0.3.6+20160429" +version = "1.0.0+20160429" authors = ["Sebastian Thiel "] description = "A complete library to interact with proximitybeacon (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/proximitybeacon1_beta1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-proximitybeacon1_beta1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-proximitybeacon1_beta1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-proximitybeacon1_beta1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-proximitybeacon1_beta1] path = "../proximitybeacon1_beta1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/proximitybeacon1_beta1-cli/README.md b/gen/proximitybeacon1_beta1-cli/README.md index ba8eb2f406..e6242910f1 100644 --- a/gen/proximitybeacon1_beta1-cli/README.md +++ b/gen/proximitybeacon1_beta1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *proximitybeacon* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/proximitybeacon1-beta1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/proximitybeacon1-beta1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/proximitybeacon1-beta1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/proximitybeacon1-beta1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/proximitybeacon1_beta1-cli). # Usage -This documentation was generated from the *proximitybeacon* API at revision *20160429*. The CLI is at version *0.3.6*. +This documentation was generated from the *proximitybeacon* API at revision *20160429*. The CLI is at version *1.0.0*. ```bash proximitybeacon1-beta1 [options] diff --git a/gen/proximitybeacon1_beta1-cli/mkdocs.yml b/gen/proximitybeacon1_beta1-cli/mkdocs.yml index e1e948b16f..d1403d4c79 100644 --- a/gen/proximitybeacon1_beta1-cli/mkdocs.yml +++ b/gen/proximitybeacon1_beta1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: proximitybeacon v0.3.6+20160429 +site_name: proximitybeacon v1.0.0+20160429 site_url: http://byron.github.io/google-apis-rs/google-proximitybeacon1_beta1-cli site_description: Write integrating applications with bcore diff --git a/gen/proximitybeacon1_beta1-cli/src/main.rs b/gen/proximitybeacon1_beta1-cli/src/main.rs index df315b098a..df7638fa92 100644 --- a/gen/proximitybeacon1_beta1-cli/src/main.rs +++ b/gen/proximitybeacon1_beta1-cli/src/main.rs @@ -1697,7 +1697,7 @@ fn main() { let mut app = App::new("proximitybeacon1-beta1") .author("Sebastian Thiel ") - .version("0.3.6+20160429") + .version("1.0.0+20160429") .about("Registers, manages, indexes, and searches beacons.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli") .arg(Arg::with_name("url") diff --git a/gen/pubsub1-cli/Cargo.toml b/gen/pubsub1-cli/Cargo.toml index a470bb0689..1ac3234f86 100644 --- a/gen/pubsub1-cli/Cargo.toml +++ b/gen/pubsub1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-pubsub1-cli" -version = "0.3.6+20160317" +version = "1.0.0+20160317" authors = ["Sebastian Thiel "] description = "A complete library to interact with pubsub (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/pubsub1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-pubsub1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-pubsub1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-pubsub1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-pubsub1] path = "../pubsub1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/pubsub1-cli/README.md b/gen/pubsub1-cli/README.md index 44a5c24981..a33bd54c46 100644 --- a/gen/pubsub1-cli/README.md +++ b/gen/pubsub1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *pubsub* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/pubsub1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/pubsub1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/pubsub1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/pubsub1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/pubsub1-cli). # Usage -This documentation was generated from the *pubsub* API at revision *20160317*. The CLI is at version *0.3.6*. +This documentation was generated from the *pubsub* API at revision *20160317*. The CLI is at version *1.0.0*. ```bash pubsub1 [options] diff --git a/gen/pubsub1-cli/mkdocs.yml b/gen/pubsub1-cli/mkdocs.yml index 0ceea2e9a0..2782d79689 100644 --- a/gen/pubsub1-cli/mkdocs.yml +++ b/gen/pubsub1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: pubsub v0.3.6+20160317 +site_name: pubsub v1.0.0+20160317 site_url: http://byron.github.io/google-apis-rs/google-pubsub1-cli site_description: Write integrating applications with bcore diff --git a/gen/pubsub1-cli/src/main.rs b/gen/pubsub1-cli/src/main.rs index 6eb742f438..1843b92de0 100644 --- a/gen/pubsub1-cli/src/main.rs +++ b/gen/pubsub1-cli/src/main.rs @@ -2149,7 +2149,7 @@ fn main() { let mut app = App::new("pubsub1") .author("Sebastian Thiel ") - .version("0.3.6+20160317") + .version("1.0.0+20160317") .about("Provides reliable, many-to-many, asynchronous messaging between applications.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_pubsub1_cli") .arg(Arg::with_name("url") diff --git a/gen/pubsub1_beta2-cli/Cargo.toml b/gen/pubsub1_beta2-cli/Cargo.toml index cd5a3137bb..0465529c14 100644 --- a/gen/pubsub1_beta2-cli/Cargo.toml +++ b/gen/pubsub1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-pubsub1_beta2-cli" -version = "0.3.6+20160317" +version = "1.0.0+20160317" authors = ["Sebastian Thiel "] description = "A complete library to interact with pubsub (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/pubsub1_beta2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-pubsub1_beta2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-pubsub1_beta2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-pubsub1_beta2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-pubsub1_beta2] path = "../pubsub1_beta2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/pubsub1_beta2-cli/README.md b/gen/pubsub1_beta2-cli/README.md index 2d73aefe73..d3bcce20fd 100644 --- a/gen/pubsub1_beta2-cli/README.md +++ b/gen/pubsub1_beta2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *pubsub* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/pubsub1-beta2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/pubsub1-beta2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/pubsub1-beta2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/pubsub1-beta2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/pubsub1_beta2-cli). # Usage -This documentation was generated from the *pubsub* API at revision *20160317*. The CLI is at version *0.3.6*. +This documentation was generated from the *pubsub* API at revision *20160317*. The CLI is at version *1.0.0*. ```bash pubsub1-beta2 [options] diff --git a/gen/pubsub1_beta2-cli/mkdocs.yml b/gen/pubsub1_beta2-cli/mkdocs.yml index b7636b7674..362a966268 100644 --- a/gen/pubsub1_beta2-cli/mkdocs.yml +++ b/gen/pubsub1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: pubsub v0.3.6+20160317 +site_name: pubsub v1.0.0+20160317 site_url: http://byron.github.io/google-apis-rs/google-pubsub1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/pubsub1_beta2-cli/src/main.rs b/gen/pubsub1_beta2-cli/src/main.rs index 5951cbd84c..11376376b8 100644 --- a/gen/pubsub1_beta2-cli/src/main.rs +++ b/gen/pubsub1_beta2-cli/src/main.rs @@ -2150,7 +2150,7 @@ fn main() { let mut app = App::new("pubsub1-beta2") .author("Sebastian Thiel ") - .version("0.3.6+20160317") + .version("1.0.0+20160317") .about("Provides reliable, many-to-many, asynchronous messaging between applications.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_pubsub1_beta2_cli") .arg(Arg::with_name("url") diff --git a/gen/qpxexpress1-cli/Cargo.toml b/gen/qpxexpress1-cli/Cargo.toml index 6eb8aacb36..4327260041 100644 --- a/gen/qpxexpress1-cli/Cargo.toml +++ b/gen/qpxexpress1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-qpxexpress1-cli" -version = "0.3.6+20160708" +version = "1.0.0+20160708" authors = ["Sebastian Thiel "] description = "A complete library to interact with QPX Express (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/qpxexpress1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-qpxexpress1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-qpxexpress1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-qpxexpress1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-qpxexpress1] path = "../qpxexpress1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/qpxexpress1-cli/README.md b/gen/qpxexpress1-cli/README.md index 2b47f299e0..cf2339ba2b 100644 --- a/gen/qpxexpress1-cli/README.md +++ b/gen/qpxexpress1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *QPX Express* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/qpxexpress1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/qpxexpress1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/qpxexpress1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/qpxexpress1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/qpxexpress1-cli). # Usage -This documentation was generated from the *QPX Express* API at revision *20160708*. The CLI is at version *0.3.6*. +This documentation was generated from the *QPX Express* API at revision *20160708*. The CLI is at version *1.0.0*. ```bash qpxexpress1 [options] diff --git a/gen/qpxexpress1-cli/mkdocs.yml b/gen/qpxexpress1-cli/mkdocs.yml index 021c49e0d4..451b9d9a02 100644 --- a/gen/qpxexpress1-cli/mkdocs.yml +++ b/gen/qpxexpress1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: QPX Express v0.3.6+20160708 +site_name: QPX Express v1.0.0+20160708 site_url: http://byron.github.io/google-apis-rs/google-qpxexpress1-cli site_description: Write integrating applications with bcore diff --git a/gen/qpxexpress1-cli/src/main.rs b/gen/qpxexpress1-cli/src/main.rs index ba973ca41f..e8d34c9a79 100644 --- a/gen/qpxexpress1-cli/src/main.rs +++ b/gen/qpxexpress1-cli/src/main.rs @@ -264,7 +264,7 @@ fn main() { let mut app = App::new("qpxexpress1") .author("Sebastian Thiel ") - .version("0.3.6+20160708") + .version("1.0.0+20160708") .about("Finds the least expensive flights between an origin and a destination.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_qpxexpress1_cli") .arg(Arg::with_name("folder") diff --git a/gen/replicapool1_beta2-cli/Cargo.toml b/gen/replicapool1_beta2-cli/Cargo.toml index 0161e10cd3..f3b45f91b9 100644 --- a/gen/replicapool1_beta2-cli/Cargo.toml +++ b/gen/replicapool1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-replicapool1_beta2-cli" -version = "0.3.6+20160512" +version = "1.0.0+20160512" authors = ["Sebastian Thiel "] description = "A complete library to interact with replicapool (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/replicapool1_beta2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-replicapool1_beta2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-replicapool1_beta2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-replicapool1_beta2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-replicapool1_beta2] path = "../replicapool1_beta2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/replicapool1_beta2-cli/README.md b/gen/replicapool1_beta2-cli/README.md index 4cd04829b0..cdf94875fc 100644 --- a/gen/replicapool1_beta2-cli/README.md +++ b/gen/replicapool1_beta2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *replicapool* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/replicapool1-beta2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/replicapool1-beta2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/replicapool1-beta2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/replicapool1-beta2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/replicapool1_beta2-cli). # Usage -This documentation was generated from the *replicapool* API at revision *20160512*. The CLI is at version *0.3.6*. +This documentation was generated from the *replicapool* API at revision *20160512*. The CLI is at version *1.0.0*. ```bash replicapool1-beta2 [options] diff --git a/gen/replicapool1_beta2-cli/mkdocs.yml b/gen/replicapool1_beta2-cli/mkdocs.yml index 5c3e070331..cbb863e192 100644 --- a/gen/replicapool1_beta2-cli/mkdocs.yml +++ b/gen/replicapool1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: replicapool v0.3.6+20160512 +site_name: replicapool v1.0.0+20160512 site_url: http://byron.github.io/google-apis-rs/google-replicapool1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/replicapool1_beta2-cli/src/main.rs b/gen/replicapool1_beta2-cli/src/main.rs index 4da7d26d4b..0a498e3e9c 100644 --- a/gen/replicapool1_beta2-cli/src/main.rs +++ b/gen/replicapool1_beta2-cli/src/main.rs @@ -1489,7 +1489,7 @@ fn main() { let mut app = App::new("replicapool1-beta2") .author("Sebastian Thiel ") - .version("0.3.6+20160512") + .version("1.0.0+20160512") .about("[Deprecated. Please use Instance Group Manager in Compute API] Provides groups of homogenous Compute Engine instances.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_replicapool1_beta2_cli") .arg(Arg::with_name("url") diff --git a/gen/replicapoolupdater1_beta1-cli/Cargo.toml b/gen/replicapoolupdater1_beta1-cli/Cargo.toml index eee7431aeb..a22a2b5a7f 100644 --- a/gen/replicapoolupdater1_beta1-cli/Cargo.toml +++ b/gen/replicapoolupdater1_beta1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-replicapoolupdater1_beta1-cli" -version = "0.3.6+20160229" +version = "1.0.0+20160229" authors = ["Sebastian Thiel "] description = "A complete library to interact with replicapoolupdater (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/replicapoolupdater1_beta1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-replicapoolupdater1_beta1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-replicapoolupdater1_beta1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-replicapoolupdater1_beta1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-replicapoolupdater1_beta1] path = "../replicapoolupdater1_beta1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/replicapoolupdater1_beta1-cli/README.md b/gen/replicapoolupdater1_beta1-cli/README.md index 0e2c7b8f20..71ac99b0ad 100644 --- a/gen/replicapoolupdater1_beta1-cli/README.md +++ b/gen/replicapoolupdater1_beta1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *replicapoolupdater* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/replicapoolupdater1-beta1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/replicapoolupdater1-beta1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/replicapoolupdater1-beta1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/replicapoolupdater1-beta1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/replicapoolupdater1_beta1-cli). # Usage -This documentation was generated from the *replicapoolupdater* API at revision *20160229*. The CLI is at version *0.3.6*. +This documentation was generated from the *replicapoolupdater* API at revision *20160229*. The CLI is at version *1.0.0*. ```bash replicapoolupdater1-beta1 [options] diff --git a/gen/replicapoolupdater1_beta1-cli/mkdocs.yml b/gen/replicapoolupdater1_beta1-cli/mkdocs.yml index 57c6c44151..e7024927c7 100644 --- a/gen/replicapoolupdater1_beta1-cli/mkdocs.yml +++ b/gen/replicapoolupdater1_beta1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: replicapoolupdater v0.3.6+20160229 +site_name: replicapoolupdater v1.0.0+20160229 site_url: http://byron.github.io/google-apis-rs/google-replicapoolupdater1_beta1-cli site_description: Write integrating applications with bcore diff --git a/gen/replicapoolupdater1_beta1-cli/src/main.rs b/gen/replicapoolupdater1_beta1-cli/src/main.rs index 62f5790fa7..20dc68b745 100644 --- a/gen/replicapoolupdater1_beta1-cli/src/main.rs +++ b/gen/replicapoolupdater1_beta1-cli/src/main.rs @@ -1117,7 +1117,7 @@ fn main() { let mut app = App::new("replicapoolupdater1-beta1") .author("Sebastian Thiel ") - .version("0.3.6+20160229") + .version("1.0.0+20160229") .about("Updates groups of Compute Engine instances.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_replicapoolupdater1_beta1_cli") .arg(Arg::with_name("url") diff --git a/gen/reseller1_sandbox-cli/Cargo.toml b/gen/reseller1_sandbox-cli/Cargo.toml index cf3338e34a..38c3c78a30 100644 --- a/gen/reseller1_sandbox-cli/Cargo.toml +++ b/gen/reseller1_sandbox-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-reseller1_sandbox-cli" -version = "0.3.6+20160329" +version = "1.0.0+20160329" authors = ["Sebastian Thiel "] description = "A complete library to interact with reseller (protocol v1sandbox)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/reseller1_sandbox-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-reseller1_sandbox/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-reseller1_sandbox/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-reseller1_sandbox/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-reseller1_sandbox] path = "../reseller1_sandbox" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/reseller1_sandbox-cli/README.md b/gen/reseller1_sandbox-cli/README.md index 23ea1790bd..e6b8144ac0 100644 --- a/gen/reseller1_sandbox-cli/README.md +++ b/gen/reseller1_sandbox-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *reseller* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/reseller1-sandbox.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/reseller1-sandbox.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/reseller1-sandbox.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/reseller1-sandbox.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/reseller1_sandbox-cli). # Usage -This documentation was generated from the *reseller* API at revision *20160329*. The CLI is at version *0.3.6*. +This documentation was generated from the *reseller* API at revision *20160329*. The CLI is at version *1.0.0*. ```bash reseller1-sandbox [options] diff --git a/gen/reseller1_sandbox-cli/mkdocs.yml b/gen/reseller1_sandbox-cli/mkdocs.yml index 97fd8a8e32..0799997ee6 100644 --- a/gen/reseller1_sandbox-cli/mkdocs.yml +++ b/gen/reseller1_sandbox-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: reseller v0.3.6+20160329 +site_name: reseller v1.0.0+20160329 site_url: http://byron.github.io/google-apis-rs/google-reseller1_sandbox-cli site_description: Write integrating applications with bcore diff --git a/gen/reseller1_sandbox-cli/src/main.rs b/gen/reseller1_sandbox-cli/src/main.rs index 7be6de6730..7bcb42d460 100644 --- a/gen/reseller1_sandbox-cli/src/main.rs +++ b/gen/reseller1_sandbox-cli/src/main.rs @@ -1645,7 +1645,7 @@ fn main() { let mut app = App::new("reseller1-sandbox") .author("Sebastian Thiel ") - .version("0.3.6+20160329") + .version("1.0.0+20160329") .about("Creates and manages your customers and their subscriptions.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_reseller1_sandbox_cli") .arg(Arg::with_name("url") diff --git a/gen/resourceviews1_beta2-cli/Cargo.toml b/gen/resourceviews1_beta2-cli/Cargo.toml index 5136fa4fe8..c1395b01b7 100644 --- a/gen/resourceviews1_beta2-cli/Cargo.toml +++ b/gen/resourceviews1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-resourceviews1_beta2-cli" -version = "0.3.6+20160512" +version = "1.0.0+20160512" authors = ["Sebastian Thiel "] description = "A complete library to interact with resourceviews (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/resourceviews1_beta2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-resourceviews1_beta2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-resourceviews1_beta2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-resourceviews1_beta2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-resourceviews1_beta2] path = "../resourceviews1_beta2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/resourceviews1_beta2-cli/README.md b/gen/resourceviews1_beta2-cli/README.md index 2953cc98b6..91f34cf988 100644 --- a/gen/resourceviews1_beta2-cli/README.md +++ b/gen/resourceviews1_beta2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *resourceviews* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/resourceviews1-beta2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/resourceviews1-beta2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/resourceviews1-beta2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/resourceviews1-beta2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/resourceviews1_beta2-cli). # Usage -This documentation was generated from the *resourceviews* API at revision *20160512*. The CLI is at version *0.3.6*. +This documentation was generated from the *resourceviews* API at revision *20160512*. The CLI is at version *1.0.0*. ```bash resourceviews1-beta2 [options] diff --git a/gen/resourceviews1_beta2-cli/mkdocs.yml b/gen/resourceviews1_beta2-cli/mkdocs.yml index af8b721347..60ed277895 100644 --- a/gen/resourceviews1_beta2-cli/mkdocs.yml +++ b/gen/resourceviews1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: resourceviews v0.3.6+20160512 +site_name: resourceviews v1.0.0+20160512 site_url: http://byron.github.io/google-apis-rs/google-resourceviews1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/resourceviews1_beta2-cli/src/main.rs b/gen/resourceviews1_beta2-cli/src/main.rs index a34b2b1a03..a4c6f27dd0 100644 --- a/gen/resourceviews1_beta2-cli/src/main.rs +++ b/gen/resourceviews1_beta2-cli/src/main.rs @@ -1322,7 +1322,7 @@ fn main() { let mut app = App::new("resourceviews1-beta2") .author("Sebastian Thiel ") - .version("0.3.6+20160512") + .version("1.0.0+20160512") .about("The Resource View API allows users to create and manage logical sets of Google Compute Engine instances.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_resourceviews1_beta2_cli") .arg(Arg::with_name("url") diff --git a/gen/safebrowsing4-cli/Cargo.toml b/gen/safebrowsing4-cli/Cargo.toml index 4ff3b6f321..7c78acf4d6 100644 --- a/gen/safebrowsing4-cli/Cargo.toml +++ b/gen/safebrowsing4-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-safebrowsing4-cli" -version = "0.3.6+20160520" +version = "1.0.0+20160520" authors = ["Sebastian Thiel "] description = "A complete library to interact with safebrowsing (protocol v4)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/safebrowsing4-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-safebrowsing4/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-safebrowsing4/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-safebrowsing4/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-safebrowsing4] path = "../safebrowsing4" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/safebrowsing4-cli/README.md b/gen/safebrowsing4-cli/README.md index 1439d271de..3b89314a6b 100644 --- a/gen/safebrowsing4-cli/README.md +++ b/gen/safebrowsing4-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *safebrowsing* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/safebrowsing4.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/safebrowsing4.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/safebrowsing4.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/safebrowsing4.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/safebrowsing4-cli). # Usage -This documentation was generated from the *safebrowsing* API at revision *20160520*. The CLI is at version *0.3.6*. +This documentation was generated from the *safebrowsing* API at revision *20160520*. The CLI is at version *1.0.0*. ```bash safebrowsing4 [options] diff --git a/gen/safebrowsing4-cli/mkdocs.yml b/gen/safebrowsing4-cli/mkdocs.yml index 55435da6b5..3dff4f9046 100644 --- a/gen/safebrowsing4-cli/mkdocs.yml +++ b/gen/safebrowsing4-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: safebrowsing v0.3.6+20160520 +site_name: safebrowsing v1.0.0+20160520 site_url: http://byron.github.io/google-apis-rs/google-safebrowsing4-cli site_description: Write integrating applications with bcore diff --git a/gen/safebrowsing4-cli/src/main.rs b/gen/safebrowsing4-cli/src/main.rs index 34bc39e3a4..3b5333ffe2 100644 --- a/gen/safebrowsing4-cli/src/main.rs +++ b/gen/safebrowsing4-cli/src/main.rs @@ -583,7 +583,7 @@ fn main() { let mut app = App::new("safebrowsing4") .author("Sebastian Thiel ") - .version("0.3.6+20160520") + .version("1.0.0+20160520") .about("Enables client applications to check web resources (most commonly URLs) against Google-generated lists of unsafe web resources.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_safebrowsing4_cli") .arg(Arg::with_name("folder") diff --git a/gen/script1-cli/Cargo.toml b/gen/script1-cli/Cargo.toml deleted file mode 100644 index 25f1a79832..0000000000 --- a/gen/script1-cli/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-script1-cli" -version = "0.3.5+20150922" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with script (protocol v1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/script1-cli" -homepage = "https://developers.google.com/apps-script/execution/rest/v1/run" -documentation = "http://byron.github.io/google-apis-rs/google_script1_cli" -license = "MIT" -keywords = ["script", "google", "cli"] - -[[bin]] -name = "script1" - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -strsim = "^0.4" -yup-hyper-mock = "^1.0" -clap = "^2.0" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-script1/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-script1/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - - -[dependencies.google-script1] -path = "../script1" -optional = true -default-features = false diff --git a/gen/script1-cli/LICENSE.md b/gen/script1-cli/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/script1-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/script1-cli/README.md b/gen/script1-cli/README.md deleted file mode 100644 index df4827ef63..0000000000 --- a/gen/script1-cli/README.md +++ /dev/null @@ -1,113 +0,0 @@ - -The `script1` command-line interface *(CLI)* allows to use most features of the *Google script* service from the comfort of your terminal. - -By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's -capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. - -If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. - -Everything else about the *script* API can be found at the -[official documentation site](https://developers.google.com/apps-script/execution/rest/v1/run). - -# Downloads - -You can download the pre-compiled 64bit binaries for the following platforms: - -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.5/ubuntu/script1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.5/osx/script1.tar.gz) - -Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/script1-cli). - -# Usage - -This documentation was generated from the *script* API at revision *20150922*. The CLI is at version *0.3.5*. - -```bash -script1 [options] - scripts - run (-r )... [-p ]... [-o ] - script1 --help - -Configuration: - [--scope ]... - Specify the authentication a method should be executed in. Each scope - requires the user to grant this application permission to use it. - If unset, it defaults to the shortest scope url for a particular method. - --config-dir - A directory into which we will store our persistent data. Defaults to - a user-writable directory that we will create during the first invocation. - [default: ~/.google-service-cli] - --debug - Output all server communication to standard error. `tx` and `rx` are placed - into the same stream. - --debug-auth - Output all communication related to authentication to standard error. `tx` - and `rx` are placed into the same stream. - -``` - -# Configuration - -The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `script1-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. - -More information about the various kinds of persistent data are given in the following paragraphs. - -# Authentication - -Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the -set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. - -If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a -method that is read-only, it will ask only for a read-only scope. -You may use the `--scope` flag to specify a scope directly. -All applicable scopes are documented in the respective method's CLI documentation. - -The first time a scope is used, the user is asked for permission. Follow the instructions given -by the CLI to grant permissions, or to decline. - -If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration -directory, e.g. `~/.google-service-cli/script1-token-.json`. No manual management of these tokens -is necessary. - -To revoke granted authentication, please refer to the [official documentation][revoke-access]. - -# Application Secrets - -In order to allow any application to use Google services, it will need to be registered using the -[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it -one by one. Most APIs can be used for free and have a daily quota. - -To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI -comes with a default application secret that is configured accordingly. This also means that heavy usage -all around the world may deplete the daily quota. - -You can workaround this limitation by putting your own secrets file at this location: -`~/.google-service-cli/script1-secret.json`, assuming that the required *script* API -was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at -*APIs & auth -> Credentials -> Download JSON* and used as is. - -Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. - - -# Debugging - -Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know -what exactly led to a particular issue. This is done by allowing all client-server communication to be -output to standard error *as-is*. - -The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag -will cause all communication related to authentication to standard error. -If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the -issue at hand. - -You may consider redirecting standard error into a file for ease of use, e.g. `script1 --debug [options] 2>debug.txt`. - - -[scopes]: https://developers.google.com/+/api/oauth#scopes -[revoke-access]: http://webapps.stackexchange.com/a/30849 -[google-dev-console]: https://console.developers.google.com/ -[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/script1-cli/mkdocs.yml b/gen/script1-cli/mkdocs.yml deleted file mode 100644 index d3276fbb8c..0000000000 --- a/gen/script1-cli/mkdocs.yml +++ /dev/null @@ -1,17 +0,0 @@ -site_name: script v0.3.5+20150922 -site_url: http://byron.github.io/google-apis-rs/google-script1-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/script1-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['scripts_run.md', 'Scripts', 'Run'] - -theme: readthedocs - -copyright: Copyright © 2015-2016, `Sebastian Thiel` - diff --git a/gen/script1-cli/src/cmn.rs b/gen/script1-cli/src/cmn.rs deleted file mode 100644 index 779c1dc086..0000000000 --- a/gen/script1-cli/src/cmn.rs +++ /dev/null @@ -1,721 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use serde_json as json; -use serde_json::value::Value; -use mime::Mime; -use clap::{App, SubCommand}; -use strsim; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - - -pub enum ComplexType { - Pod, - Vec, - Map, -} - - // Null, - // Bool(bool), - // I64(i64), - // U64(u64), - // F64(f64), - // String(String), - -pub enum JsonType { - Boolean, - Int, - Uint, - Float, - String, -} - -pub struct JsonTypeInfo { - pub jtype: JsonType, - pub ctype: ComplexType, -} - -// Based on @erickt user comment. Thanks for the idea ! -// Remove all keys whose values are null from given value (changed in place) -pub fn remove_json_null_values(value: &mut Value) { - match *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); - } - } - _ => {} - } -} - -fn did_you_mean<'a>(v: &str, possible_values: &[&'a str]) -> Option<&'a str> { - - let mut candidate: Option<(f64, &str)> = None; - for pv in possible_values { - let confidence = strsim::jaro_winkler(v, pv); - if confidence > 0.8 && (candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence)) { - candidate = Some((confidence, pv)); - } - } - match candidate { - None => None, - Some((_, candidate)) => Some(candidate), - } -} - -pub enum CallType { - Upload(UploadProtocol), - Standard, -} - -arg_enum!{ - pub enum UploadProtocol { - Simple, - Resumable - } -} - -impl AsRef for UploadProtocol { - fn as_ref(&self) -> &str { - match *self { - UploadProtocol::Simple => "simple", - UploadProtocol::Resumable => "resumable" - } - } -} - -impl AsRef for CallType { - fn as_ref(&self) -> &str { - match *self { - CallType::Upload(ref proto) => proto.as_ref(), - CallType::Standard => "standard-request" - } - } -} - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.join(".") - } -} - -impl From<&'static str> for FieldCursor { - fn from(value: &'static str) -> FieldCursor { - let mut res = FieldCursor::default(); - res.set(value).unwrap(); - res - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn did_you_mean(value: &str, possible_values: &[&str]) -> Option { - if value.len() == 0 { - return None - } - - let mut last_c = FIELD_SEP; - - let mut field = String::new(); - let mut output = String::new(); - - let push_field = |fs: &mut String, f: &mut String| { - if f.len() > 0 { - fs.push_str( - match did_you_mean(&f, possible_values) { - Some(candidate) => candidate, - None => &f, - }); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - if c == FIELD_SEP { - if last_c != FIELD_SEP { - push_field(&mut output, &mut field); - } - output.push(c); - } else { - field.push(c); - } - - last_c = c; - } - - push_field(&mut output, &mut field); - - if &output == value { - None - } else { - Some(output) - } - } - - pub fn set_json_value(&self, mut object: &mut Value, - value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, - orig_cursor: &FieldCursor) { - assert!(self.0.len() > 0); - - for field in &self.0[..self.0.len()-1] { - let tmp = object; - object = - match *tmp { - Value::Object(ref mut mapping) => { - mapping.entry(field.to_owned()).or_insert( - Value::Object(Default::default()) - ) - }, - _ => panic!("We don't expect non-object Values here ...") - }; - } - - match *object { - Value::Object(ref mut mapping) => { - let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| - -> Value { - match jtype { - JsonType::Boolean => - Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => - Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => - Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => - Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => - Value::String(value.to_owned()), - } - }; - - match type_info.ctype { - ComplexType::Pod => { - if mapping.insert(field.to_owned(), to_jval(value, type_info.jtype, err)).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - }, - ComplexType::Vec => { - match *mapping.entry(field.to_owned()) - .or_insert(Value::Array(Default::default())) { - Value::Array(ref mut values) => values.push(to_jval(value, type_info.jtype, err)), - _ => unreachable!() - } - }, - ComplexType::Map => { - let (key, value) = parse_kv_arg(value, err, true); - let jval = to_jval(value.unwrap_or(""), type_info.jtype, err); - - match *mapping.entry(field.to_owned()) - .or_insert(Value::Object(Default::default())) { - Value::Object(ref mut value_map) => { - if value_map.insert(key.to_owned(), jval).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - } - _ => unreachable!() - } - } - } - }, - _ => unreachable!() - } - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); - match kv.find('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, Some("")) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut InvalidOptionsError) -> CallType { - CallType::Upload( - match UploadProtocol::from_str(name) { - Ok(up) => up, - Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); - UploadProtocol::Simple - } - }) -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::Io((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { - let f = arg.unwrap_or("-"); - match f { - "-" => Ok(Box::new(stdout())), - _ => match fs::OpenOptions::new().create(true).write(true).open(f) { - Ok(f) => Ok(Box::new(f)), - Err(io_err) => Err(io_err), - } - } -} - - -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, - arg_type: &'a str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError(arg_name.to_owned(), arg_type.to_owned(), arg.to_string(), format!("{}", perr)) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - type Error = json::Error; - - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Result<(), json::Error> { - match token { - None => { - match fs::remove_file(self.path(scope_hash)) { - Err(err) => - match err.kind() { - io::ErrorKind::NotFound => Ok(()), - _ => Err(json::Error::Io(err)) - }, - Ok(_) => Ok(()), - } - } - Some(token) => { - match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { - Ok(mut f) => { - match json::to_writer_pretty(&mut f, &token) { - Ok(_) => Ok(()), - Err(serde_err) => Err(serde_err), - } - }, - Err(io_err) => Err(json::Error::Io(io_err)) - } - } - } - } - - fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, json::Error> { - match fs::File::open(&self.path(scope_hash)) { - Ok(f) => { - match json::de::from_reader(f) { - Ok(token) => Ok(Some(token)), - Err(err) => Err(err), - } - }, - Err(io_err) => { - match io_err.kind() { - io::ErrorKind::NotFound => Ok(None), - _ => Err(json::Error::Io(io_err)) - } - } - } - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::Error)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - Io((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty."), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::Io((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}.", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - Io((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::Io((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}.", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type.", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String, Option, Option), - Duplicate(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor.", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character.", field), - FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = - match *suggestion { - Some(ref s) => { - let kv = - match *value { - Some(ref v) => format!("{}={}", s, v), - None => s.clone(), - }; - format!(" Did you mean '{}' ?", kv) - }, - None => String::new(), - }; - writeln!(f, "Field '{}' does not exist.{}", field, suffix) - }, - FieldError::Duplicate(ref cursor) - => writeln!(f, "Value at '{}' was already set", cursor), - FieldError::Empty - => writeln!(f, "Field names must not be empty."), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError(String, String, String, String), - UnknownParameter(String, Vec<&'static str>), - InvalidUploadProtocol(String, Vec), - InvalidKeyValueSyntax(String, bool), - Input(InputError), - Field(FieldError), - MissingCommandError, - MissingMethodError(String), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let suffix = - match did_you_mean(param_name, &possible_values) { - Some(v) => format!(" Did you mean '{}' ?", v), - None => String::new(), - }; - write!(f, "Parameter '{}' is unknown.{}\n", param_name, suffix) - }, - CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { - let hashmap_info = if is_hashmap { "hashmap " } else { "" }; - writeln!(f, "'{}' does not match {}pattern =.", kv, hashmap_info) - }, - CLIError::MissingCommandError => writeln!(f, "Please specify the main sub-command."), - CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the '{}' command.", cmd), - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, - json_console_secret: &str) - -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::Io( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret - = json::from_str(json_console_secret).unwrap(); - match json::to_writer_pretty(&mut f, &console_secret) { - Err(serde_err) => match serde_err { - json::Error::Io(err) => err, - _ => panic!("Unexpected serde error: {:#?}", serde_err) - }, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(f) => { - match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::Io(err)) => - return secret_io_error(err), - Err(json_err) => - return Err(CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::DecoderError( - (secret_str(), json_err) - )))), - Ok(console_secret) => - match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} diff --git a/gen/script1-cli/src/main.rs b/gen/script1-cli/src/main.rs deleted file mode 100644 index f765f5cb71..0000000000 --- a/gen/script1-cli/src/main.rs +++ /dev/null @@ -1,365 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -#[macro_use] -extern crate clap; -extern crate yup_oauth2 as oauth2; -extern crate yup_hyper_mock as mock; -extern crate serde; -extern crate serde_json; -extern crate hyper; -extern crate mime; -extern crate strsim; -extern crate google_script1 as api; - -use std::env; -use std::io::{self, Write}; -use clap::{App, SubCommand, Arg}; - -mod cmn; - -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol, - calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, FlowType}; -use serde_json as json; -use clap::ArgMatches; - -enum DoitError { - IoError(String, io::Error), - ApiError(api::Error), -} - -struct Engine<'n> { - opt: ArgMatches<'n>, - hub: api::Script>, - gp: Vec<&'static str>, - gpm: Vec<(&'static str, &'static str)>, -} - - -impl<'n> Engine<'n> { - fn _scripts_run(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "function" => Some(("function", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "dev-mode" => Some(("devMode", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "session-state" => Some(("sessionState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["dev-mode", "function", "session-state"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::ExecutionRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.scripts().run(request, opt.value_of("script-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _doit(&self, dry_run: bool) -> Result, Option> { - let mut err = InvalidOptionsError::new(); - let mut call_result: Result<(), DoitError> = Ok(()); - let mut err_opt: Option = None; - match self.opt.subcommand() { - ("scripts", Some(opt)) => { - match opt.subcommand() { - ("run", Some(opt)) => { - call_result = self._scripts_run(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("scripts".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - _ => { - err.issues.push(CLIError::MissingCommandError); - writeln!(io::stderr(), "{}\n", self.opt.usage()).ok(); - } - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - Err(err_opt) - } else { - Ok(call_result) - } - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: ArgMatches<'n>) -> Result, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "script1-secret.json", - "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, - if opt.is_present("debug-auth") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }, - JsonTokenStorage { - program_name: "script1", - db_dir: config_dir.clone(), - }, Some(FlowType::InstalledInteractive)); - - let client = - if opt.is_present("debug") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }; - let engine = Engine { - opt: opt, - hub: api::Script::new(client, auth), - gp: vec!["$-xgafv", "access-token", "alt", "bearer-token", "callback", "fields", "key", "oauth-token", "pp", "pretty-print", "quota-user", "upload-type", "upload-protocol"], - gpm: vec![ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("upload-type", "uploadType"), - ("upload-protocol", "upload_protocol"), - ] - }; - - match engine._doit(true) { - Err(Some(err)) => Err(err), - Err(None) => Ok(engine), - Ok(_) => unreachable!(), - } - } - - fn doit(&self) -> Result<(), DoitError> { - match self._doit(false) { - Ok(res) => res, - Err(_) => unreachable!(), - } - } -} - -fn main() { - let mut exit_status = 0i32; - let arg_data = [ - ("scripts", "methods: 'run'", vec![ - ("run", - Some(r##"Runs a function in an Apps Script project that has been deployed for use with the Apps Script Execution API. This method requires authorization with an OAuth 2.0 token that includes at least one of the scopes listed in the [Authentication](#authentication) section; script projects that do not require authorization cannot be executed through this API. To find the correct scopes to include in the authentication token, open the project in the script editor, then select **File > Project properties** and click the **Scopes** tab."##), - "Details at http://byron.github.io/google-apis-rs/google_script1_cli/scripts_run", - vec![ - (Some(r##"script-id"##), - None, - Some(r##"The project key of the script to be executed. To find the project key, open the project in the script editor, then select **File > Project properties**."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ]; - - let mut app = App::new("script1") - .author("Sebastian Thiel ") - .version("0.3.5+20150922") - .about("An API for executing Google Apps Script projects.") - .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_script1_cli") - .arg(Arg::with_name("url") - .long("scope") - .help("Specify the authentication a method should be executed in. Each scope requires the user to grant this application permission to use it.If unset, it defaults to the shortest scope url for a particular method.") - .multiple(true) - .takes_value(true)) - .arg(Arg::with_name("folder") - .long("config-dir") - .help("A directory into which we will store our persistent data. Defaults to a user-writable directory that we will create during the first invocation.[default: ~/.google-service-cli") - .multiple(false) - .takes_value(true)) - .arg(Arg::with_name("debug") - .long("debug") - .help("Output all server communication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)) - .arg(Arg::with_name("debug-auth") - .long("debug-auth") - .help("Output all communication related to authentication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)); - - for &(main_command_name, about, ref subcommands) in arg_data.iter() { - let mut mcmd = SubCommand::with_name(main_command_name).about(about); - - for &(sub_command_name, ref desc, url_info, ref args) in subcommands { - let mut scmd = SubCommand::with_name(sub_command_name); - if let &Some(desc) = desc { - scmd = scmd.about(desc); - } - scmd = scmd.after_help(url_info); - - for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args { - let arg_name_str = - match (arg_name, flag) { - (&Some(an), _ ) => an, - (_ , &Some(f)) => f, - _ => unreachable!(), - }; - let mut arg = Arg::with_name(arg_name_str) - .empty_values(false); - if let &Some(short_flag) = flag { - arg = arg.short(short_flag); - } - if let &Some(desc) = desc { - arg = arg.help(desc); - } - if arg_name.is_some() && flag.is_some() { - arg = arg.takes_value(true); - } - if let &Some(required) = required { - arg = arg.required(required); - } - if let &Some(multi) = multi { - arg = arg.multiple(multi); - } - scmd = scmd.arg(arg); - } - mcmd = mcmd.subcommand(scmd); - } - app = app.subcommand(mcmd); - } - - let matches = app.get_matches(); - - let debug = matches.is_present("debug"); - match Engine::new(matches) { - Err(err) => { - exit_status = err.exit_code; - writeln!(io::stderr(), "{}", err).ok(); - }, - Ok(engine) => { - if let Err(doit_err) = engine.doit() { - exit_status = 1; - match doit_err { - DoitError::IoError(path, err) => { - writeln!(io::stderr(), "Failed to open output file '{}': {}", path, err).ok(); - }, - DoitError::ApiError(err) => { - if debug { - writeln!(io::stderr(), "{:#?}", err).ok(); - } else { - writeln!(io::stderr(), "{}", err).ok(); - } - } - } - } - } - } - - std::process::exit(exit_status); -} \ No newline at end of file diff --git a/gen/script1/Cargo.toml b/gen/script1/Cargo.toml deleted file mode 100644 index 0bfa60c40e..0000000000 --- a/gen/script1/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-script1" -version = "0.1.14+20150922" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with script (protocol v1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/script1" -homepage = "https://developers.google.com/apps-script/execution/rest/v1/run" -documentation = "http://byron.github.io/google-apis-rs/google_script1" -license = "MIT" -keywords = ["script", "google", "protocol", "web", "api"] -build = "src/build.rs" - - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -url = "= 0.5" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - diff --git a/gen/script1/LICENSE.md b/gen/script1/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/script1/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/script1/README.md b/gen/script1/README.md deleted file mode 100644 index 4f859bb770..0000000000 --- a/gen/script1/README.md +++ /dev/null @@ -1,179 +0,0 @@ - -The `google-script1` library allows access to all features of the *Google script* service. - -This documentation was generated from *script* crate version *0.1.14+20150922*, where *20150922* is the exact revision of the *script:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. - -Everything else about the *script* *v1* API can be found at the -[official documentation site](https://developers.google.com/apps-script/execution/rest/v1/run). -# Features - -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_script1/struct.Script.html) ... - -* scripts - * [*run*](http://byron.github.io/google-apis-rs/google_script1/struct.ScriptRunCall.html) - - - - -# Structure of this Library - -The API is structured into the following primary items: - -* **[Hub](http://byron.github.io/google-apis-rs/google_script1/struct.Script.html)** - * a central object to maintain state and allow accessing all *Activities* - * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_script1/trait.MethodsBuilder.html) which in turn - allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_script1/trait.CallBuilder.html) -* **[Resources](http://byron.github.io/google-apis-rs/google_script1/trait.Resource.html)** - * primary types that you can apply *Activities* to - * a collection of properties and *Parts* - * **[Parts](http://byron.github.io/google-apis-rs/google_script1/trait.Part.html)** - * a collection of properties - * never directly used in *Activities* -* **[Activities](http://byron.github.io/google-apis-rs/google_script1/trait.CallBuilder.html)** - * 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() -``` - -Or specifically ... - -```ignore -let r = hub.scripts().run(...).doit() -``` - -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-script1 = "*" -``` - -## A complete example - -```Rust -extern crate hyper; -extern crate yup_oauth2 as oauth2; -extern crate google_script1 as script1; -use script1::ExecutionRequest; -use script1::{Result, Error}; -use std::default::Default; -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use script1::Script; - -// Get an ApplicationSecret instance by some means. It contains the `client_id` and -// `client_secret`, among other things. -let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - ::default(), None); -let mut hub = Script::new(hyper::Client::new(), 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 = ExecutionRequest::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.scripts().run(req, "scriptId") - .doit(); - -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::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](http://byron.github.io/google-apis-rs/google_script1/enum.Result.html) enumeration as return value of -the doit() methods, or handed as possibly intermediate results to either the -[Hub Delegate](http://byron.github.io/google-apis-rs/google_script1/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_script1/../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](http://byron.github.io/google-apis-rs/google_script1/enum.Result.html), should be -read by you to obtain the media. -If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_script1/trait.ResponseResult.html), 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](http://byron.github.io/google-apis-rs/google_script1/trait.Delegate.html) to the -[Method Builder](http://byron.github.io/google-apis-rs/google_script1/trait.CallBuilder.html) 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](http://byron.github.io/google-apis-rs/google_script1/trait.Delegate.html) 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 [enocodable](http://byron.github.io/google-apis-rs/google_script1/trait.RequestValue.html) and -[decodable](http://byron.github.io/google-apis-rs/google_script1/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -are valid. -Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_script1/trait.Part.html) 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](http://byron.github.io/google-apis-rs/google_script1/trait.CallBuilder.html), 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](http://byron.github.io/google-apis-rs/google_script1/trait.RequestValue.html) 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 **script1** 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-rs/LICENSE.md diff --git a/gen/script1/src/build.rs b/gen/script1/src/build.rs deleted file mode 100644 index 0bebaf0bf0..0000000000 --- a/gen/script1/src/build.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[cfg(feature = "with-serde-codegen")] -mod inner { - extern crate serde_codegen; - - use std::env; - use std::path::Path; - - pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - - let src = Path::new("src/lib.rs.in"); - let dst = Path::new(&out_dir).join("lib.rs"); - - serde_codegen::expand(&src, &dst).unwrap(); - } -} - -#[cfg(not(feature = "with-serde-codegen"))] -mod inner { - pub fn main() {} -} - -pub fn main() { - inner::main() -} \ No newline at end of file diff --git a/gen/script1/src/cmn.rs b/gen/script1/src/cmn.rs deleted file mode 100644 index d75063e466..0000000000 --- a/gen/script1/src/cmn.rs +++ /dev/null @@ -1,753 +0,0 @@ -// COPY OF 'src/rust/api/cmn.rs' -// DO NOT EDIT -use std::io::{self, Read, Seek, Cursor, Write, SeekFrom}; -use std; -use std::fmt::{self, Display}; -use std::str::FromStr; -use std::error; -use std::thread::sleep; -use std::time::Duration; - -use mime::{Mime, TopLevel, SubLevel, Attr, Value}; -use oauth2::{TokenType, Retry, self}; -use hyper; -use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header, - HeaderFormat, Bearer}; -use hyper::http::h1::LINE_ENDING; -use hyper::method::Method; -use hyper::status::StatusCode; - -use serde_json as json; - -/// 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 {} -impl 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 utility type which can decode a server response that indicates error -#[derive(Deserialize)] -pub struct JsonServerError { - pub error: String, - pub error_description: Option -} - -/// A utility to represent detailed errors we might see in case there are BadRequests. -/// The latter happen if the sent parameters or request structures are unsound -#[derive(Deserialize, Serialize, Debug)] -pub struct ErrorResponse { - error: ServerError, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerError { - errors: Vec, - code: u16, - message: String, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerMessage { - domain: String, - reason: String, - message: String, - #[serde(rename="locationType")] - location_type: Option, - location: Option -} - -#[derive(Copy, Clone)] -pub struct DummyNetworkStream; - -impl Read for DummyNetworkStream { - fn read(&mut self, _: &mut [u8]) -> io::Result { - Ok(0) - } -} - -impl Write for DummyNetworkStream { - fn write(&mut self, _: &[u8]) -> io::Result { - Ok(0) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl hyper::net::NetworkStream for DummyNetworkStream { - fn peer_addr(&mut self) -> io::Result { - Ok("127.0.0.1:1337".parse().unwrap()) - } - - fn set_read_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } - - fn set_write_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } -} - - -/// 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 { - - /// 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, MethodInfo) {} - - /// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), 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, &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 { - 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: &error::Error) -> Option { - 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 { - 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::client::Response, Option, _: Option) -> 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(ErrorResponse), - - /// 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(Box), - - /// 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::client::Response), -} - - -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - 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 err) => { - try!(writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message)); - for err in err.error.errors.iter() { - try!(writeln!(f, " {}: {}, {}{}", - err.domain, - err.message, - err.reason, - match &err.location { - &Some(ref loc) => format!("@{}", loc), - &None => String::new(), - })); - } - 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 description(&self) -> &str { - match *self { - Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(_, ref err) => err.description(), - _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" - } - } - - fn cause(&self) -> Option<&error::Error> { - match *self { - Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(_, ref err) => err.cause(), - _ => None - } - } -} - -/// A universal result type used as return for all calls. -pub type Result = std::result::Result; - -/// Contains information about an API request. -pub struct MethodInfo { - pub id: &'static str, - pub http_method: Method, -} - -const BOUNDARY: &'static 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<(Headers, &'a mut Read)>, - current_part: Option<(Cursor>, &'a mut Read)>, - last_part_boundary: Option>>, -} - -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 Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> { - let mut headers = Headers::new(); - headers.set(ContentType(mime_type)); - headers.set(ContentLength(size)); - 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.len() == 0 && 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.len() == 0 && self.current_part.is_some() - } -} - -impl<'a> Read for MultiPartReader<'a> { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - 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::::new()); - (write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING, - headers, 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).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<'a>(&'a self) -> &'a Mime { &self.0 } -} -impl ::std::ops::DerefMut for XUploadContentType { - fn deref_mut<'a>(&'a mut self) -> &'a mut Mime { &mut self.0 } -} -impl Header for XUploadContentType { - fn header_name() -> &'static str { "X-Upload-Content-Type" } - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - hyper::header::parsing::from_one_raw_str(raw).map(XUploadContentType) - } -} -impl HeaderFormat for XUploadContentType { - fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&**self, f) - } -} -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 { - 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, - pub total_length: u64, -} - -impl Header for ContentRange { - fn header_name() -> &'static str { - "Content-Range" - } - - /// We are not parsable, as parsing is done by the `Range` header - fn parse_header(_: &[Vec]) -> hyper::error::Result { - Err(hyper::error::Error::Method) - } -} - - -impl HeaderFormat for ContentRange { - fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes ")); - match self.range { - Some(ref c) => try!(c.fmt(fmt)), - None => try!(fmt.write_str("*")) - } - (write!(fmt, "/{}", self.total_length)).ok(); - Ok(()) - } -} - -#[derive(Clone, PartialEq, Debug)] -pub struct RangeResponseHeader(pub Chunk); - -impl Header for RangeResponseHeader { - fn header_name() -> &'static str { - "Range" - } - - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - if raw.len() > 0 { - let v = &raw[0]; - if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes "; - if s.starts_with(PREFIX) { - if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { - return Ok(RangeResponseHeader(c)) - } - } - } - } - Err(hyper::error::Error::Method) - } -} - -impl HeaderFormat for RangeResponseHeader { - /// No implmentation necessary, we just need to parse - fn fmt_header(&self, _: &mut fmt::Formatter) -> fmt::Result { - Err(fmt::Error) - } -} - -/// A utility type to perform a resumable upload from start to end. -pub struct ResumableUploadHelper<'a, A: 'a> { - pub client: &'a mut hyper::client::Client, - pub delegate: &'a mut Delegate, - pub start_at: Option, - pub auth: &'a mut A, - pub user_agent: &'a str, - pub auth_header: Authorization, - pub url: &'a str, - pub reader: &'a mut ReadSeek, - pub media_type: Mime, - pub content_length: u64 -} - -impl<'a, A> ResumableUploadHelper<'a, A> - where A: oauth2::GetToken { - - fn query_transfer_status(&mut self) -> std::result::Result> { - loop { - match self.client.post(self.url) - .header(UserAgent(self.user_agent.to_string())) - .header(ContentRange { range: None, total_length: self.content_length }) - .header(self.auth_header.clone()) - .send() { - Ok(r) => { - // 308 = resume-incomplete == PermanentRedirect - let headers = r.headers.clone(); - let h: &RangeResponseHeader = match headers.get() { - Some(hh) if r.status == StatusCode::PermanentRedirect => hh, - None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None, 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 fn upload(&mut self) -> Option> { - let mut start = match self.start_at { - Some(s) => s, - None => match self.query_transfer_status() { - 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 - }; - - self.reader.seek(SeekFrom::Start(start)).unwrap(); - loop { - 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 range_header = ContentRange { - range: Some(Chunk {first: start, last: start + request_size - 1}), - total_length: self.content_length - }; - start += request_size; - if self.delegate.cancel_chunk_upload(&range_header) { - return None - } - let res = self.client.post(self.url) - .header(range_header) - .header(ContentType(self.media_type.clone())) - .header(UserAgent(self.user_agent.to_string())) - .body(&mut section_reader) - .send(); - match res { - Ok(mut res) => { - if res.status == StatusCode::PermanentRedirect { - continue - } - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - } - return Some(Ok(res)) - }, - Err(err) => { - if let Retry::After(d) = self.delegate.http_error(&err) { - sleep(d); - continue; - } - return Some(Err(err)) - } - } - } - } -} - -// Copy of src/rust/cli/cmn.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); - } - } - _ => {} - } -} diff --git a/gen/script1/src/lib.rs b/gen/script1/src/lib.rs deleted file mode 100644 index a39d1219ee..0000000000 --- a/gen/script1/src/lib.rs +++ /dev/null @@ -1,189 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.mako' -// DO NOT EDIT ! - -//! This documentation was generated from *script* crate version *0.1.14+20150922*, where *20150922* is the exact revision of the *script:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. -//! -//! Everything else about the *script* *v1* API can be found at the -//! [official documentation site](https://developers.google.com/apps-script/execution/rest/v1/run). -//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/script1). -//! # Features -//! -//! Handle the following *Resources* with ease from the central [hub](struct.Script.html) ... -//! -//! * scripts -//! * [*run*](struct.ScriptRunCall.html) -//! -//! -//! -//! -//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html). -//! -//! # Structure of this Library -//! -//! The API is structured into the following primary items: -//! -//! * **[Hub](struct.Script.html)** -//! * a central object to maintain state and allow accessing all *Activities* -//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn -//! allow access to individual [*Call Builders*](trait.CallBuilder.html) -//! * **[Resources](trait.Resource.html)** -//! * primary types that you can apply *Activities* to -//! * a collection of properties and *Parts* -//! * **[Parts](trait.Part.html)** -//! * a collection of properties -//! * never directly used in *Activities* -//! * **[Activities](trait.CallBuilder.html)** -//! * 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() -//! ``` -//! -//! Or specifically ... -//! -//! ```ignore -//! let r = hub.scripts().run(...).doit() -//! ``` -//! -//! 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-script1 = "*" -//! ``` -//! -//! ## A complete example -//! -//! ```test_harness,no_run -//! extern crate hyper; -//! extern crate yup_oauth2 as oauth2; -//! extern crate google_script1 as script1; -//! use script1::ExecutionRequest; -//! use script1::{Result, Error}; -//! # #[test] fn egal() { -//! use std::default::Default; -//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use script1::Script; -//! -//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and -//! // `client_secret`, among other things. -//! let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -//! hyper::Client::new(), -//! ::default(), None); -//! let mut hub = Script::new(hyper::Client::new(), 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 = ExecutionRequest::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.scripts().run(req, "scriptId") -//! .doit(); -//! -//! 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::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](enum.Result.html) enumeration as return value of -//! the doit() methods, or handed as possibly intermediate results to either the -//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../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](enum.Result.html), should be -//! read by you to obtain the media. -//! If such a method also supports a [Response Result](trait.ResponseResult.html), 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](trait.Delegate.html) to the -//! [Method Builder](trait.CallBuilder.html) 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](trait.Delegate.html) 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 [enocodable](trait.RequestValue.html) and -//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -//! are valid. -//! Most optionals are are considered [Parts](trait.Part.html) 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](trait.CallBuilder.html), 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](trait.RequestValue.html) 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 ... . -#![cfg_attr(feature = "nightly", feature(custom_derive, custom_attribute, plugin))] -#![cfg_attr(feature = "nightly", plugin(serde_macros))] -#![allow(unused_imports, unused_mut, dead_code)] - -#[cfg(feature = "nightly")] -include!("lib.rs.in"); - -#[cfg(feature = "with-serde-codegen")] -include!(concat!(env!("OUT_DIR"), "/lib.rs")); \ No newline at end of file diff --git a/gen/script1/src/lib.rs.in b/gen/script1/src/lib.rs.in deleted file mode 100644 index b5ce50a0e3..0000000000 --- a/gen/script1/src/lib.rs.in +++ /dev/null @@ -1,611 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.in.mako' -// DO NOT EDIT ! - -extern crate hyper; -extern crate serde; -extern crate serde_json; -extern crate yup_oauth2 as oauth2; -extern crate mime; -extern crate url; - -mod cmn; - -use std::collections::HashMap; -use std::cell::RefCell; -use std::borrow::BorrowMut; -use std::default::Default; -use std::collections::BTreeMap; -use serde_json as json; -use std::io; -use std::fs; -use std::thread::sleep; -use std::time::Duration; - -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, - ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, - Resource, ErrorResponse, remove_json_null_values}; - - -// ############## -// UTILITIES ### -// ############ - -/// Identifies the an OAuth2 authorization scope. -/// A scope is needed when requesting an -/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). -#[derive(PartialEq, Eq, Hash)] -pub enum Scope { - /// View and manage the files in your Google Drive - Drive, - - /// View and manage your mail - Scrip, - - /// View and manage forms that this application has been installed in - FormCurrentonly, - - /// View and manage the provisioning of users on your domain - AdminDirectoryUser, - - /// Manage your contacts - Feed, - - /// View and manage your Google Groups - Group, - - /// View and manage the provisioning of groups on your domain - AdminDirectoryGroup, - - /// View and manage your forms in Google Drive - Form, - - /// Manage your calendars - Feed, - - /// View your email address - UserinfoEmail, -} - -impl AsRef for Scope { - fn as_ref(&self) -> &str { - match *self { - Scope::Drive => "https://www.googleapis.com/auth/drive", - Scope::Scrip => "https://mail.google.com/", - Scope::FormCurrentonly => "https://www.googleapis.com/auth/forms.currentonly", - Scope::AdminDirectoryUser => "https://www.googleapis.com/auth/admin.directory.user", - Scope::Feed => "https://www.google.com/m8/feeds", - Scope::Group => "https://www.googleapis.com/auth/groups", - Scope::AdminDirectoryGroup => "https://www.googleapis.com/auth/admin.directory.group", - Scope::Form => "https://www.googleapis.com/auth/forms", - Scope::Feed => "https://www.google.com/calendar/feeds", - Scope::UserinfoEmail => "https://www.googleapis.com/auth/userinfo.email", - } - } -} - -impl Default for Scope { - fn default() -> Scope { - Scope::Scrip - } -} - - - -// ######## -// HUB ### -// ###### - -/// Central instance to access all Script related resource activities -/// -/// # Examples -/// -/// Instantiate a new hub -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_script1 as script1; -/// use script1::ExecutionRequest; -/// use script1::{Result, Error}; -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use script1::Script; -/// -/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and -/// // `client_secret`, among other things. -/// let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Script::new(hyper::Client::new(), 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 = ExecutionRequest::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.scripts().run(req, "scriptId") -/// .doit(); -/// -/// 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::MissingAPIKey -/// |Error::MissingToken(_) -/// |Error::Cancelled -/// |Error::UploadSizeLimitExceeded(_, _) -/// |Error::Failure(_) -/// |Error::BadRequest(_) -/// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_, _) => println!("{}", e), -/// }, -/// Ok(res) => println!("Success: {:?}", res), -/// } -/// # } -/// ``` -pub struct Script { - client: RefCell, - auth: RefCell, - _user_agent: String, -} - -impl<'a, C, A> Hub for Script {} - -impl<'a, C, A> Script - where C: BorrowMut, A: oauth2::GetToken { - - pub fn new(client: C, authenticator: A) -> Script { - Script { - client: RefCell::new(client), - auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.14".to_string(), - } - } - - pub fn scripts(&'a self) -> ScriptMethods<'a, C, A> { - ScriptMethods { hub: &self } - } - - /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.14`. - /// - /// Returns the previously set user-agent. - pub fn user_agent(&mut self, agent_name: String) -> String { - let prev = self._user_agent.clone(); - self._user_agent = agent_name; - prev - } -} - - -// ############ -// SCHEMAS ### -// ########## -/// If a `run` call succeeds but the script function (or Apps Script itself) throws an exception, the response body's `error` field will contain this `Status` object. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Status { - /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. - pub message: Option, - /// The status code, which should be an enum value of google.rpc.Code. - pub code: Option, - /// An array that contains a single `ExecutionError` object that provides information about the nature of the error. - pub details: Option>>, -} - -impl Part for Status {} - - -/// A request to run the function in a script. The script is identified by the specified `script_id`. Executing a function on a script will return results based on the implementation of the script. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [run scripts](struct.ScriptRunCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ExecutionRequest { - /// The name of the function to execute in the given script. The name does not include parentheses or parameters. - pub function: Option, - /// This field is not used. - #[serde(rename="sessionState")] - pub session_state: Option, - /// The parameters to be passed to the function being executed. The type for each parameter should match the expected type in Apps Script. Parameters cannot be Apps Script-specific objects (such as a `Document` or `Calendar`); they can only be primitive types such as a `string`, `number`, `array`, `object`, or `boolean`. Optional. - pub parameters: Option>, - /// If `true` and the user is an owner of the script, the script runs at the most recently saved version rather than the version deployed for use with the Execution API. Optional; default is `false`. - #[serde(rename="devMode")] - pub dev_mode: Option, -} - -impl RequestValue for ExecutionRequest {} - - -/// The response will not arrive until the function finishes executing. The maximum runtime is listed in the guide to [limitations in Apps Script](https://developers.google.com/apps-script/guides/services/quotas#current_limitations). -/// If the script function returns successfully, the `response` field will contain an `ExecutionResponse` object with the function's return value in the object's `result` field. -/// -/// If the script function (or Apps Script itself) throws an exception, the `error` field will contain a `Status` object. The `Status` object's `details` field will contain an array with a single `ExecutionError` object that provides information about the nature of the error. -/// -/// If the `run` call itself fails (for example, because of a malformed request or an authorization error), the method will return an HTTP response code in the 4XX range with a different format for the response body. Client libraries will automatically convert a 4XX response into an exception class. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [run scripts](struct.ScriptRunCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Operation { - /// This field is not used. - pub metadata: Option>, - /// This field is not used. - pub done: Option, - /// If the script function returns successfully, this field will contain an `ExecutionResponse` object with the function's return value as the object's `result` field. - pub response: Option>, - /// This field is not used. - pub name: Option, - /// If a `run` call succeeds but the script function (or Apps Script itself) throws an exception, this field will contain a `Status` object. The `Status` object's `details` field will contain an array with a single `ExecutionError` object that provides information about the nature of the error. - pub error: Option, -} - -impl ResponseResult for Operation {} - - - -// ################### -// MethodBuilders ### -// ################# - -/// A builder providing access to all methods supported on *script* resources. -/// It is not used directly, but through the `Script` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_script1 as script1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use script1::Script; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Script::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `run(...)` -/// // to build up your call. -/// let rb = hub.scripts(); -/// # } -/// ``` -pub struct ScriptMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Script, -} - -impl<'a, C, A> MethodsBuilder for ScriptMethods<'a, C, A> {} - -impl<'a, C, A> ScriptMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Runs a function in an Apps Script project that has been deployed for use with the Apps Script Execution API. This method requires authorization with an OAuth 2.0 token that includes at least one of the scopes listed in the [Authentication](#authentication) section; script projects that do not require authorization cannot be executed through this API. To find the correct scopes to include in the authentication token, open the project in the script editor, then select **File > Project properties** and click the **Scopes** tab. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `scriptId` - The project key of the script to be executed. To find the project key, open the project in the script editor, then select **File > Project properties**. - pub fn run(&self, request: ExecutionRequest, script_id: &str) -> ScriptRunCall<'a, C, A> { - ScriptRunCall { - hub: self.hub, - _request: request, - _script_id: script_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - - - -// ################### -// CallBuilders ### -// ################# - -/// Runs a function in an Apps Script project that has been deployed for use with the Apps Script Execution API. This method requires authorization with an OAuth 2.0 token that includes at least one of the scopes listed in the [Authentication](#authentication) section; script projects that do not require authorization cannot be executed through this API. To find the correct scopes to include in the authentication token, open the project in the script editor, then select **File > Project properties** and click the **Scopes** tab. -/// -/// A builder for the *run* method supported by a *script* resource. -/// It is not used directly, but through a `ScriptMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_script1 as script1; -/// use script1::ExecutionRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use script1::Script; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Script::new(hyper::Client::new(), 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 = ExecutionRequest::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.scripts().run(req, "scriptId") -/// .doit(); -/// # } -/// ``` -pub struct ScriptRunCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Script, - _request: ExecutionRequest, - _script_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ScriptRunCall<'a, C, A> {} - -impl<'a, C, A> ScriptRunCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "script.scripts.run", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("scriptId", self._script_id.to_string())); - for &field in ["alt", "scriptId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://script.googleapis.com/v1/scripts/{scriptId}:run".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Scrip.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{scriptId}", "scriptId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["scriptId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: ExecutionRequest) -> ScriptRunCall<'a, C, A> { - self._request = new_value; - self - } - /// The project key of the script to be executed. To find the project key, open the project in the script editor, then select **File > Project properties**. - /// - /// Sets the *script id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn script_id(mut self, new_value: &str) -> ScriptRunCall<'a, C, A> { - self._script_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ScriptRunCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *bearer_token* (query-string) - OAuth bearer token. - /// * *pp* (query-boolean) - Pretty-print response. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). - /// * *access_token* (query-string) - OAuth access token. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - /// * *callback* (query-string) - JSONP - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). - /// * *alt* (query-string) - Data format for response. - /// * *$.xgafv* (query-string) - V1 error format. - pub fn param(mut self, name: T, value: T) -> ScriptRunCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Scrip`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ScriptRunCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - diff --git a/gen/serviceregistryalpha-cli/Cargo.toml b/gen/serviceregistryalpha-cli/Cargo.toml index 6db2481b5a..671eddfb2d 100644 --- a/gen/serviceregistryalpha-cli/Cargo.toml +++ b/gen/serviceregistryalpha-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-serviceregistryalpha-cli" -version = "0.3.6+20160401" +version = "1.0.0+20160401" authors = ["Sebastian Thiel "] description = "A complete library to interact with Service Registry (protocol alpha)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/serviceregistryalpha-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-serviceregistryalpha/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-serviceregistryalpha/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-serviceregistryalpha/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-serviceregistryalpha] path = "../serviceregistryalpha" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/serviceregistryalpha-cli/README.md b/gen/serviceregistryalpha-cli/README.md index 6f08f399b3..0d2c2bd5dd 100644 --- a/gen/serviceregistryalpha-cli/README.md +++ b/gen/serviceregistryalpha-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Service Registry* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/serviceregistryalpha.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/serviceregistryalpha.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/serviceregistryalpha.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/serviceregistryalpha.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/serviceregistryalpha-cli). # Usage -This documentation was generated from the *Service Registry* API at revision *20160401*. The CLI is at version *0.3.6*. +This documentation was generated from the *Service Registry* API at revision *20160401*. The CLI is at version *1.0.0*. ```bash serviceregistryalpha [options] diff --git a/gen/serviceregistryalpha-cli/mkdocs.yml b/gen/serviceregistryalpha-cli/mkdocs.yml index 8637a4f1c3..94eccbc636 100644 --- a/gen/serviceregistryalpha-cli/mkdocs.yml +++ b/gen/serviceregistryalpha-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Service Registry v0.3.6+20160401 +site_name: Service Registry v1.0.0+20160401 site_url: http://byron.github.io/google-apis-rs/google-serviceregistryalpha-cli site_description: Write integrating applications with bcore diff --git a/gen/serviceregistryalpha-cli/src/main.rs b/gen/serviceregistryalpha-cli/src/main.rs index af78e003a5..aa25953117 100644 --- a/gen/serviceregistryalpha-cli/src/main.rs +++ b/gen/serviceregistryalpha-cli/src/main.rs @@ -974,7 +974,7 @@ fn main() { let mut app = App::new("serviceregistryalpha") .author("Sebastian Thiel ") - .version("0.3.6+20160401") + .version("1.0.0+20160401") .about("Manages service endpoints in Service Registry and provides integration with DNS for service discovery and name resolution.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_serviceregistryalpha_cli") .arg(Arg::with_name("url") diff --git a/gen/siteverification1-cli/Cargo.toml b/gen/siteverification1-cli/Cargo.toml index c4d2ab0740..a128158069 100644 --- a/gen/siteverification1-cli/Cargo.toml +++ b/gen/siteverification1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-siteverification1-cli" -version = "0.3.6+20160228" +version = "1.0.0+20160228" authors = ["Sebastian Thiel "] description = "A complete library to interact with siteVerification (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/siteverification1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-siteverification1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-siteverification1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-siteverification1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-siteverification1] path = "../siteverification1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/siteverification1-cli/README.md b/gen/siteverification1-cli/README.md index 2b3fe60442..46b9954d26 100644 --- a/gen/siteverification1-cli/README.md +++ b/gen/siteverification1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *siteVerification* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/siteverification1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/siteverification1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/siteverification1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/siteverification1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/siteverification1-cli). # Usage -This documentation was generated from the *siteVerification* API at revision *20160228*. The CLI is at version *0.3.6*. +This documentation was generated from the *siteVerification* API at revision *20160228*. The CLI is at version *1.0.0*. ```bash siteverification1 [options] diff --git a/gen/siteverification1-cli/mkdocs.yml b/gen/siteverification1-cli/mkdocs.yml index 3f5d1525dc..1b2a2b9839 100644 --- a/gen/siteverification1-cli/mkdocs.yml +++ b/gen/siteverification1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: siteVerification v0.3.6+20160228 +site_name: siteVerification v1.0.0+20160228 site_url: http://byron.github.io/google-apis-rs/google-siteverification1-cli site_description: Write integrating applications with bcore diff --git a/gen/siteverification1-cli/src/main.rs b/gen/siteverification1-cli/src/main.rs index 7473349173..1605128ef7 100644 --- a/gen/siteverification1-cli/src/main.rs +++ b/gen/siteverification1-cli/src/main.rs @@ -827,7 +827,7 @@ fn main() { let mut app = App::new("siteverification1") .author("Sebastian Thiel ") - .version("0.3.6+20160228") + .version("1.0.0+20160228") .about("Verifies ownership of websites or domains with Google.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_siteverification1_cli") .arg(Arg::with_name("url") diff --git a/gen/spectrum1_explorer-cli/Cargo.toml b/gen/spectrum1_explorer-cli/Cargo.toml index ee9b0bcea2..561a774451 100644 --- a/gen/spectrum1_explorer-cli/Cargo.toml +++ b/gen/spectrum1_explorer-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-spectrum1_explorer-cli" -version = "0.3.6+20160606" +version = "1.0.0+20160606" authors = ["Sebastian Thiel "] description = "A complete library to interact with spectrum (protocol v1explorer)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/spectrum1_explorer-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-spectrum1_explorer/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-spectrum1_explorer/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-spectrum1_explorer/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-spectrum1_explorer] path = "../spectrum1_explorer" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/spectrum1_explorer-cli/README.md b/gen/spectrum1_explorer-cli/README.md index 8e5ca5c9e3..270fd7a72a 100644 --- a/gen/spectrum1_explorer-cli/README.md +++ b/gen/spectrum1_explorer-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *spectrum* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/spectrum1-explorer.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/spectrum1-explorer.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/spectrum1-explorer.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/spectrum1-explorer.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/spectrum1_explorer-cli). # Usage -This documentation was generated from the *spectrum* API at revision *20160606*. The CLI is at version *0.3.6*. +This documentation was generated from the *spectrum* API at revision *20160606*. The CLI is at version *1.0.0*. ```bash spectrum1-explorer [options] diff --git a/gen/spectrum1_explorer-cli/mkdocs.yml b/gen/spectrum1_explorer-cli/mkdocs.yml index 1b0523be3f..d5e0d2e8e4 100644 --- a/gen/spectrum1_explorer-cli/mkdocs.yml +++ b/gen/spectrum1_explorer-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: spectrum v0.3.6+20160606 +site_name: spectrum v1.0.0+20160606 site_url: http://byron.github.io/google-apis-rs/google-spectrum1_explorer-cli site_description: Write integrating applications with bcore diff --git a/gen/spectrum1_explorer-cli/src/main.rs b/gen/spectrum1_explorer-cli/src/main.rs index dc10fdccd4..ea5155ef84 100644 --- a/gen/spectrum1_explorer-cli/src/main.rs +++ b/gen/spectrum1_explorer-cli/src/main.rs @@ -960,7 +960,7 @@ fn main() { let mut app = App::new("spectrum1-explorer") .author("Sebastian Thiel ") - .version("0.3.6+20160606") + .version("1.0.0+20160606") .about("API for spectrum-management functions.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_spectrum1_explorer_cli") .arg(Arg::with_name("folder") diff --git a/gen/sqladmin1_beta4-cli/Cargo.toml b/gen/sqladmin1_beta4-cli/Cargo.toml index 89f2df48ab..f2fb26622c 100644 --- a/gen/sqladmin1_beta4-cli/Cargo.toml +++ b/gen/sqladmin1_beta4-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-sqladmin1_beta4-cli" -version = "0.3.6+20160907" +version = "1.0.0+20160907" authors = ["Sebastian Thiel "] description = "A complete library to interact with SQL Admin (protocol v1beta4)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/sqladmin1_beta4-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-sqladmin1_beta4/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-sqladmin1_beta4/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-sqladmin1_beta4/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-sqladmin1_beta4] path = "../sqladmin1_beta4" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/sqladmin1_beta4-cli/README.md b/gen/sqladmin1_beta4-cli/README.md index caee45d482..ed98d617a4 100644 --- a/gen/sqladmin1_beta4-cli/README.md +++ b/gen/sqladmin1_beta4-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *SQL Admin* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/sqladmin1-beta4.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/sqladmin1-beta4.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/sqladmin1-beta4.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/sqladmin1-beta4.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/sqladmin1_beta4-cli). # Usage -This documentation was generated from the *SQL Admin* API at revision *20160907*. The CLI is at version *0.3.6*. +This documentation was generated from the *SQL Admin* API at revision *20160907*. The CLI is at version *1.0.0*. ```bash sqladmin1-beta4 [options] diff --git a/gen/sqladmin1_beta4-cli/mkdocs.yml b/gen/sqladmin1_beta4-cli/mkdocs.yml index 5aae687d1e..adfdb79ae5 100644 --- a/gen/sqladmin1_beta4-cli/mkdocs.yml +++ b/gen/sqladmin1_beta4-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: SQL Admin v0.3.6+20160907 +site_name: SQL Admin v1.0.0+20160907 site_url: http://byron.github.io/google-apis-rs/google-sqladmin1_beta4-cli site_description: Write integrating applications with bcore diff --git a/gen/sqladmin1_beta4-cli/src/main.rs b/gen/sqladmin1_beta4-cli/src/main.rs index 5dc89814fa..e72140b013 100644 --- a/gen/sqladmin1_beta4-cli/src/main.rs +++ b/gen/sqladmin1_beta4-cli/src/main.rs @@ -4413,7 +4413,7 @@ fn main() { let mut app = App::new("sqladmin1-beta4") .author("Sebastian Thiel ") - .version("0.3.6+20160907") + .version("1.0.0+20160907") .about("Creates and configures Cloud SQL instances, which provide fully-managed MySQL databases.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_sqladmin1_beta4_cli") .arg(Arg::with_name("url") diff --git a/gen/storage1-cli/Cargo.toml b/gen/storage1-cli/Cargo.toml index 4cfa6d5e95..1e0cd1763c 100644 --- a/gen/storage1-cli/Cargo.toml +++ b/gen/storage1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-storage1-cli" -version = "0.3.6+20160901" +version = "1.0.0+20160901" authors = ["Sebastian Thiel "] description = "A complete library to interact with storage (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/storage1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-storage1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-storage1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-storage1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-storage1] path = "../storage1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/storage1-cli/README.md b/gen/storage1-cli/README.md index 5619a5acf3..41f4df4a13 100644 --- a/gen/storage1-cli/README.md +++ b/gen/storage1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *storage* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/storage1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/storage1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/storage1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/storage1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/storage1-cli). # Usage -This documentation was generated from the *storage* API at revision *20160901*. The CLI is at version *0.3.6*. +This documentation was generated from the *storage* API at revision *20160901*. The CLI is at version *1.0.0*. ```bash storage1 [options] diff --git a/gen/storage1-cli/mkdocs.yml b/gen/storage1-cli/mkdocs.yml index 4d2cf0475e..edf69e0eca 100644 --- a/gen/storage1-cli/mkdocs.yml +++ b/gen/storage1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: storage v0.3.6+20160901 +site_name: storage v1.0.0+20160901 site_url: http://byron.github.io/google-apis-rs/google-storage1-cli site_description: Write integrating applications with bcore diff --git a/gen/storage1-cli/src/main.rs b/gen/storage1-cli/src/main.rs index b2f29d951e..77eb72df1c 100644 --- a/gen/storage1-cli/src/main.rs +++ b/gen/storage1-cli/src/main.rs @@ -4494,7 +4494,7 @@ fn main() { let mut app = App::new("storage1") .author("Sebastian Thiel ") - .version("0.3.6+20160901") + .version("1.0.0+20160901") .about("Stores and retrieves potentially large, immutable data objects.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_storage1_cli") .arg(Arg::with_name("url") diff --git a/gen/storagetransfer1-cli/Cargo.toml b/gen/storagetransfer1-cli/Cargo.toml index 38580d5c16..716e88156c 100644 --- a/gen/storagetransfer1-cli/Cargo.toml +++ b/gen/storagetransfer1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-storagetransfer1-cli" -version = "0.3.6+20150811" +version = "1.0.0+20150811" authors = ["Sebastian Thiel "] description = "A complete library to interact with storagetransfer (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/storagetransfer1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-storagetransfer1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-storagetransfer1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-storagetransfer1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-storagetransfer1] path = "../storagetransfer1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/storagetransfer1-cli/README.md b/gen/storagetransfer1-cli/README.md index 74a6a0365a..3468a1c017 100644 --- a/gen/storagetransfer1-cli/README.md +++ b/gen/storagetransfer1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *storagetransfer* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/storagetransfer1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/storagetransfer1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/storagetransfer1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/storagetransfer1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/storagetransfer1-cli). # Usage -This documentation was generated from the *storagetransfer* API at revision *20150811*. The CLI is at version *0.3.6*. +This documentation was generated from the *storagetransfer* API at revision *20150811*. The CLI is at version *1.0.0*. ```bash storagetransfer1 [options] diff --git a/gen/storagetransfer1-cli/mkdocs.yml b/gen/storagetransfer1-cli/mkdocs.yml index 5996ea4551..f9de5f3ce1 100644 --- a/gen/storagetransfer1-cli/mkdocs.yml +++ b/gen/storagetransfer1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: storagetransfer v0.3.6+20150811 +site_name: storagetransfer v1.0.0+20150811 site_url: http://byron.github.io/google-apis-rs/google-storagetransfer1-cli site_description: Write integrating applications with bcore diff --git a/gen/storagetransfer1-cli/src/main.rs b/gen/storagetransfer1-cli/src/main.rs index d48a54507c..baac2238d9 100644 --- a/gen/storagetransfer1-cli/src/main.rs +++ b/gen/storagetransfer1-cli/src/main.rs @@ -1332,7 +1332,7 @@ fn main() { let mut app = App::new("storagetransfer1") .author("Sebastian Thiel ") - .version("0.3.6+20150811") + .version("1.0.0+20150811") .about("Transfers data from external data sources to a Google Cloud Storage bucket or between Google Cloud Storage buckets.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_storagetransfer1_cli") .arg(Arg::with_name("url") diff --git a/gen/tagmanager1-cli/Cargo.toml b/gen/tagmanager1-cli/Cargo.toml index 27c3c92da8..29d725e257 100644 --- a/gen/tagmanager1-cli/Cargo.toml +++ b/gen/tagmanager1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-tagmanager1-cli" -version = "0.3.6+20160310" +version = "1.0.0+20160310" authors = ["Sebastian Thiel "] description = "A complete library to interact with Tag Manager (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/tagmanager1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-tagmanager1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-tagmanager1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-tagmanager1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-tagmanager1] path = "../tagmanager1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/tagmanager1-cli/README.md b/gen/tagmanager1-cli/README.md index 2da85d25b7..cf623bdb6f 100644 --- a/gen/tagmanager1-cli/README.md +++ b/gen/tagmanager1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *Tag Manager* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/tagmanager1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/tagmanager1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/tagmanager1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/tagmanager1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/tagmanager1-cli). # Usage -This documentation was generated from the *Tag Manager* API at revision *20160310*. The CLI is at version *0.3.6*. +This documentation was generated from the *Tag Manager* API at revision *20160310*. The CLI is at version *1.0.0*. ```bash tagmanager1 [options] diff --git a/gen/tagmanager1-cli/mkdocs.yml b/gen/tagmanager1-cli/mkdocs.yml index 242870959e..85cf398f2d 100644 --- a/gen/tagmanager1-cli/mkdocs.yml +++ b/gen/tagmanager1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Tag Manager v0.3.6+20160310 +site_name: Tag Manager v1.0.0+20160310 site_url: http://byron.github.io/google-apis-rs/google-tagmanager1-cli site_description: Write integrating applications with bcore diff --git a/gen/tagmanager1-cli/src/main.rs b/gen/tagmanager1-cli/src/main.rs index 5c66e57f90..ad000de600 100644 --- a/gen/tagmanager1-cli/src/main.rs +++ b/gen/tagmanager1-cli/src/main.rs @@ -5338,7 +5338,7 @@ fn main() { let mut app = App::new("tagmanager1") .author("Sebastian Thiel ") - .version("0.3.6+20160310") + .version("1.0.0+20160310") .about("Accesses Tag Manager accounts and containers.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_tagmanager1_cli") .arg(Arg::with_name("url") diff --git a/gen/taskqueue1_beta2-cli/Cargo.toml b/gen/taskqueue1_beta2-cli/Cargo.toml index d84b16abac..f047effa78 100644 --- a/gen/taskqueue1_beta2-cli/Cargo.toml +++ b/gen/taskqueue1_beta2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-taskqueue1_beta2-cli" -version = "0.3.6+20160428" +version = "1.0.0+20160428" authors = ["Sebastian Thiel "] description = "A complete library to interact with taskqueue (protocol v1beta2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/taskqueue1_beta2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-taskqueue1_beta2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-taskqueue1_beta2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-taskqueue1_beta2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-taskqueue1_beta2] path = "../taskqueue1_beta2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/taskqueue1_beta2-cli/README.md b/gen/taskqueue1_beta2-cli/README.md index bcb8ff8ff3..8d83d8354b 100644 --- a/gen/taskqueue1_beta2-cli/README.md +++ b/gen/taskqueue1_beta2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *taskqueue* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/taskqueue1-beta2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/taskqueue1-beta2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/taskqueue1-beta2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/taskqueue1-beta2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/taskqueue1_beta2-cli). # Usage -This documentation was generated from the *taskqueue* API at revision *20160428*. The CLI is at version *0.3.6*. +This documentation was generated from the *taskqueue* API at revision *20160428*. The CLI is at version *1.0.0*. ```bash taskqueue1-beta2 [options] diff --git a/gen/taskqueue1_beta2-cli/mkdocs.yml b/gen/taskqueue1_beta2-cli/mkdocs.yml index 8cae9b3329..f753c39ee6 100644 --- a/gen/taskqueue1_beta2-cli/mkdocs.yml +++ b/gen/taskqueue1_beta2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: taskqueue v0.3.6+20160428 +site_name: taskqueue v1.0.0+20160428 site_url: http://byron.github.io/google-apis-rs/google-taskqueue1_beta2-cli site_description: Write integrating applications with bcore diff --git a/gen/taskqueue1_beta2-cli/src/main.rs b/gen/taskqueue1_beta2-cli/src/main.rs index df3d857b34..9b13dd51f5 100644 --- a/gen/taskqueue1_beta2-cli/src/main.rs +++ b/gen/taskqueue1_beta2-cli/src/main.rs @@ -1009,7 +1009,7 @@ fn main() { let mut app = App::new("taskqueue1-beta2") .author("Sebastian Thiel ") - .version("0.3.6+20160428") + .version("1.0.0+20160428") .about("Accesses a Google App Engine Pull Task Queue over REST.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_taskqueue1_beta2_cli") .arg(Arg::with_name("url") diff --git a/gen/tasks1-cli/Cargo.toml b/gen/tasks1-cli/Cargo.toml index 93c5c198d0..a893c364c5 100644 --- a/gen/tasks1-cli/Cargo.toml +++ b/gen/tasks1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-tasks1-cli" -version = "0.3.6+20141121" +version = "1.0.0+20141121" authors = ["Sebastian Thiel "] description = "A complete library to interact with tasks (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/tasks1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-tasks1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-tasks1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-tasks1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-tasks1] path = "../tasks1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/tasks1-cli/README.md b/gen/tasks1-cli/README.md index ceb232901d..e85fb4734b 100644 --- a/gen/tasks1-cli/README.md +++ b/gen/tasks1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *tasks* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/tasks1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/tasks1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/tasks1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/tasks1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/tasks1-cli). # Usage -This documentation was generated from the *tasks* API at revision *20141121*. The CLI is at version *0.3.6*. +This documentation was generated from the *tasks* API at revision *20141121*. The CLI is at version *1.0.0*. ```bash tasks1 [options] diff --git a/gen/tasks1-cli/mkdocs.yml b/gen/tasks1-cli/mkdocs.yml index 7801d0f3a0..5d62c7456b 100644 --- a/gen/tasks1-cli/mkdocs.yml +++ b/gen/tasks1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: tasks v0.3.6+20141121 +site_name: tasks v1.0.0+20141121 site_url: http://byron.github.io/google-apis-rs/google-tasks1-cli site_description: Write integrating applications with bcore diff --git a/gen/tasks1-cli/src/main.rs b/gen/tasks1-cli/src/main.rs index 220ce3e7c0..8f83a79846 100644 --- a/gen/tasks1-cli/src/main.rs +++ b/gen/tasks1-cli/src/main.rs @@ -1552,7 +1552,7 @@ fn main() { let mut app = App::new("tasks1") .author("Sebastian Thiel ") - .version("0.3.6+20141121") + .version("1.0.0+20141121") .about("Lets you manage your tasks and task lists.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_tasks1_cli") .arg(Arg::with_name("url") diff --git a/gen/toolresults1_beta3-cli/Cargo.toml b/gen/toolresults1_beta3-cli/Cargo.toml deleted file mode 100644 index f9d2b00869..0000000000 --- a/gen/toolresults1_beta3-cli/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-toolresults1_beta3-cli" -version = "0.3.5+20160408" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with Tool Results (protocol v1beta3)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/toolresults1_beta3-cli" -homepage = "https://developers.google.com/cloud-test-lab/" -documentation = "http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli" -license = "MIT" -keywords = ["toolresults", "google", "cli"] - -[[bin]] -name = "toolresults1-beta3" - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -strsim = "^0.4" -yup-hyper-mock = "^1.0" -clap = "^2.0" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-toolresults1_beta3/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-toolresults1_beta3/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - - -[dependencies.google-toolresults1_beta3] -path = "../toolresults1_beta3" -optional = true -default-features = false diff --git a/gen/toolresults1_beta3-cli/LICENSE.md b/gen/toolresults1_beta3-cli/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/toolresults1_beta3-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/toolresults1_beta3-cli/README.md b/gen/toolresults1_beta3-cli/README.md deleted file mode 100644 index df13891bd9..0000000000 --- a/gen/toolresults1_beta3-cli/README.md +++ /dev/null @@ -1,127 +0,0 @@ - -The `toolresults1-beta3` command-line interface *(CLI)* allows to use most features of the *Google Tool Results* service from the comfort of your terminal. - -By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's -capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero. - -If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools. - -Everything else about the *Tool Results* API can be found at the -[official documentation site](https://developers.google.com/cloud-test-lab/). - -# Downloads - -You can download the pre-compiled 64bit binaries for the following platforms: - -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.5/ubuntu/toolresults1-beta3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.5/osx/toolresults1-beta3.tar.gz) - -Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/toolresults1_beta3-cli). - -# Usage - -This documentation was generated from the *Tool Results* API at revision *20160408*. The CLI is at version *0.3.5*. - -```bash -toolresults1-beta3 [options] - projects - get-settings [-p ]... [-o ] - histories-create (-r )... [-p ]... [-o ] - histories-executions-create (-r )... [-p ]... [-o ] - histories-executions-get [-p ]... [-o ] - histories-executions-list [-p ]... [-o ] - histories-executions-patch (-r )... [-p ]... [-o ] - histories-executions-steps-create (-r )... [-p ]... [-o ] - histories-executions-steps-get [-p ]... [-o ] - histories-executions-steps-list [-p ]... [-o ] - histories-executions-steps-patch (-r )... [-p ]... [-o ] - histories-executions-steps-publish-xunit-xml-files (-r )... [-p ]... [-o ] - histories-executions-steps-thumbnails-list [-p ]... [-o ] - histories-get [-p ]... [-o ] - histories-list [-p ]... [-o ] - initialize-settings [-p ]... [-o ] - toolresults1-beta3 --help - -Configuration: - [--scope ]... - Specify the authentication a method should be executed in. Each scope - requires the user to grant this application permission to use it. - If unset, it defaults to the shortest scope url for a particular method. - --config-dir - A directory into which we will store our persistent data. Defaults to - a user-writable directory that we will create during the first invocation. - [default: ~/.google-service-cli] - --debug - Output all server communication to standard error. `tx` and `rx` are placed - into the same stream. - --debug-auth - Output all communication related to authentication to standard error. `tx` - and `rx` are placed into the same stream. - -``` - -# Configuration - -The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `toolresults1-beta3-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis. - -More information about the various kinds of persistent data are given in the following paragraphs. - -# Authentication - -Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the -set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*. - -If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a -method that is read-only, it will ask only for a read-only scope. -You may use the `--scope` flag to specify a scope directly. -All applicable scopes are documented in the respective method's CLI documentation. - -The first time a scope is used, the user is asked for permission. Follow the instructions given -by the CLI to grant permissions, or to decline. - -If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration -directory, e.g. `~/.google-service-cli/toolresults1-beta3-token-.json`. No manual management of these tokens -is necessary. - -To revoke granted authentication, please refer to the [official documentation][revoke-access]. - -# Application Secrets - -In order to allow any application to use Google services, it will need to be registered using the -[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it -one by one. Most APIs can be used for free and have a daily quota. - -To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI -comes with a default application secret that is configured accordingly. This also means that heavy usage -all around the world may deplete the daily quota. - -You can workaround this limitation by putting your own secrets file at this location: -`~/.google-service-cli/toolresults1-beta3-secret.json`, assuming that the required *toolresults* API -was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at -*APIs & auth -> Credentials -> Download JSON* and used as is. - -Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new]. - - -# Debugging - -Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know -what exactly led to a particular issue. This is done by allowing all client-server communication to be -output to standard error *as-is*. - -The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag -will cause all communication related to authentication to standard error. -If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the -issue at hand. - -You may consider redirecting standard error into a file for ease of use, e.g. `toolresults1-beta3 --debug [options] 2>debug.txt`. - - -[scopes]: https://developers.google.com/+/api/oauth#scopes -[revoke-access]: http://webapps.stackexchange.com/a/30849 -[google-dev-console]: https://console.developers.google.com/ -[google-project-new]: https://developers.google.com/console/help/new/ \ No newline at end of file diff --git a/gen/toolresults1_beta3-cli/mkdocs.yml b/gen/toolresults1_beta3-cli/mkdocs.yml deleted file mode 100644 index d602dcd2b6..0000000000 --- a/gen/toolresults1_beta3-cli/mkdocs.yml +++ /dev/null @@ -1,31 +0,0 @@ -site_name: Tool Results v0.3.5+20160408 -site_url: http://byron.github.io/google-apis-rs/google-toolresults1_beta3-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/toolresults1_beta3-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['projects_get-settings.md', 'Projects', 'Get Settings'] -- ['projects_histories-create.md', 'Projects', 'Histories Create'] -- ['projects_histories-executions-create.md', 'Projects', 'Histories Executions Create'] -- ['projects_histories-executions-get.md', 'Projects', 'Histories Executions Get'] -- ['projects_histories-executions-list.md', 'Projects', 'Histories Executions List'] -- ['projects_histories-executions-patch.md', 'Projects', 'Histories Executions Patch'] -- ['projects_histories-executions-steps-create.md', 'Projects', 'Histories Executions Steps Create'] -- ['projects_histories-executions-steps-get.md', 'Projects', 'Histories Executions Steps Get'] -- ['projects_histories-executions-steps-list.md', 'Projects', 'Histories Executions Steps List'] -- ['projects_histories-executions-steps-patch.md', 'Projects', 'Histories Executions Steps Patch'] -- ['projects_histories-executions-steps-publish-xunit-xml-files.md', 'Projects', 'Histories Executions Steps Publish Xunit Xml Files'] -- ['projects_histories-executions-steps-thumbnails-list.md', 'Projects', 'Histories Executions Steps Thumbnails List'] -- ['projects_histories-get.md', 'Projects', 'Histories Get'] -- ['projects_histories-list.md', 'Projects', 'Histories List'] -- ['projects_initialize-settings.md', 'Projects', 'Initialize Settings'] - -theme: readthedocs - -copyright: Copyright © 2015-2016, `Sebastian Thiel` - diff --git a/gen/toolresults1_beta3-cli/src/cmn.rs b/gen/toolresults1_beta3-cli/src/cmn.rs deleted file mode 100644 index 779c1dc086..0000000000 --- a/gen/toolresults1_beta3-cli/src/cmn.rs +++ /dev/null @@ -1,721 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use serde_json as json; -use serde_json::value::Value; -use mime::Mime; -use clap::{App, SubCommand}; -use strsim; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - - -pub enum ComplexType { - Pod, - Vec, - Map, -} - - // Null, - // Bool(bool), - // I64(i64), - // U64(u64), - // F64(f64), - // String(String), - -pub enum JsonType { - Boolean, - Int, - Uint, - Float, - String, -} - -pub struct JsonTypeInfo { - pub jtype: JsonType, - pub ctype: ComplexType, -} - -// Based on @erickt user comment. Thanks for the idea ! -// Remove all keys whose values are null from given value (changed in place) -pub fn remove_json_null_values(value: &mut Value) { - match *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); - } - } - _ => {} - } -} - -fn did_you_mean<'a>(v: &str, possible_values: &[&'a str]) -> Option<&'a str> { - - let mut candidate: Option<(f64, &str)> = None; - for pv in possible_values { - let confidence = strsim::jaro_winkler(v, pv); - if confidence > 0.8 && (candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence)) { - candidate = Some((confidence, pv)); - } - } - match candidate { - None => None, - Some((_, candidate)) => Some(candidate), - } -} - -pub enum CallType { - Upload(UploadProtocol), - Standard, -} - -arg_enum!{ - pub enum UploadProtocol { - Simple, - Resumable - } -} - -impl AsRef for UploadProtocol { - fn as_ref(&self) -> &str { - match *self { - UploadProtocol::Simple => "simple", - UploadProtocol::Resumable => "resumable" - } - } -} - -impl AsRef for CallType { - fn as_ref(&self) -> &str { - match *self { - CallType::Upload(ref proto) => proto.as_ref(), - CallType::Standard => "standard-request" - } - } -} - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.join(".") - } -} - -impl From<&'static str> for FieldCursor { - fn from(value: &'static str) -> FieldCursor { - let mut res = FieldCursor::default(); - res.set(value).unwrap(); - res - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn did_you_mean(value: &str, possible_values: &[&str]) -> Option { - if value.len() == 0 { - return None - } - - let mut last_c = FIELD_SEP; - - let mut field = String::new(); - let mut output = String::new(); - - let push_field = |fs: &mut String, f: &mut String| { - if f.len() > 0 { - fs.push_str( - match did_you_mean(&f, possible_values) { - Some(candidate) => candidate, - None => &f, - }); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - if c == FIELD_SEP { - if last_c != FIELD_SEP { - push_field(&mut output, &mut field); - } - output.push(c); - } else { - field.push(c); - } - - last_c = c; - } - - push_field(&mut output, &mut field); - - if &output == value { - None - } else { - Some(output) - } - } - - pub fn set_json_value(&self, mut object: &mut Value, - value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, - orig_cursor: &FieldCursor) { - assert!(self.0.len() > 0); - - for field in &self.0[..self.0.len()-1] { - let tmp = object; - object = - match *tmp { - Value::Object(ref mut mapping) => { - mapping.entry(field.to_owned()).or_insert( - Value::Object(Default::default()) - ) - }, - _ => panic!("We don't expect non-object Values here ...") - }; - } - - match *object { - Value::Object(ref mut mapping) => { - let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| - -> Value { - match jtype { - JsonType::Boolean => - Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => - Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => - Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => - Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => - Value::String(value.to_owned()), - } - }; - - match type_info.ctype { - ComplexType::Pod => { - if mapping.insert(field.to_owned(), to_jval(value, type_info.jtype, err)).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - }, - ComplexType::Vec => { - match *mapping.entry(field.to_owned()) - .or_insert(Value::Array(Default::default())) { - Value::Array(ref mut values) => values.push(to_jval(value, type_info.jtype, err)), - _ => unreachable!() - } - }, - ComplexType::Map => { - let (key, value) = parse_kv_arg(value, err, true); - let jval = to_jval(value.unwrap_or(""), type_info.jtype, err); - - match *mapping.entry(field.to_owned()) - .or_insert(Value::Object(Default::default())) { - Value::Object(ref mut value_map) => { - if value_map.insert(key.to_owned(), jval).is_some() { - err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string()))); - } - } - _ => unreachable!() - } - } - } - }, - _ => unreachable!() - } - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); - match kv.find('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, Some("")) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut InvalidOptionsError) -> CallType { - CallType::Upload( - match UploadProtocol::from_str(name) { - Ok(up) => up, - Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); - UploadProtocol::Simple - } - }) -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::Io((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { - let f = arg.unwrap_or("-"); - match f { - "-" => Ok(Box::new(stdout())), - _ => match fs::OpenOptions::new().create(true).write(true).open(f) { - Ok(f) => Ok(Box::new(f)), - Err(io_err) => Err(io_err), - } - } -} - - -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, - arg_type: &'a str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError(arg_name.to_owned(), arg_type.to_owned(), arg.to_string(), format!("{}", perr)) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - type Error = json::Error; - - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Result<(), json::Error> { - match token { - None => { - match fs::remove_file(self.path(scope_hash)) { - Err(err) => - match err.kind() { - io::ErrorKind::NotFound => Ok(()), - _ => Err(json::Error::Io(err)) - }, - Ok(_) => Ok(()), - } - } - Some(token) => { - match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { - Ok(mut f) => { - match json::to_writer_pretty(&mut f, &token) { - Ok(_) => Ok(()), - Err(serde_err) => Err(serde_err), - } - }, - Err(io_err) => Err(json::Error::Io(io_err)) - } - } - } - } - - fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, json::Error> { - match fs::File::open(&self.path(scope_hash)) { - Ok(f) => { - match json::de::from_reader(f) { - Ok(token) => Ok(Some(token)), - Err(err) => Err(err), - } - }, - Err(io_err) => { - match io_err.kind() { - io::ErrorKind::NotFound => Ok(None), - _ => Err(json::Error::Io(io_err)) - } - } - } - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::Error)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - Io((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty."), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::Io((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}.", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - Io((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::Io((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}.", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type.", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String, Option, Option), - Duplicate(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor.", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character.", field), - FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = - match *suggestion { - Some(ref s) => { - let kv = - match *value { - Some(ref v) => format!("{}={}", s, v), - None => s.clone(), - }; - format!(" Did you mean '{}' ?", kv) - }, - None => String::new(), - }; - writeln!(f, "Field '{}' does not exist.{}", field, suffix) - }, - FieldError::Duplicate(ref cursor) - => writeln!(f, "Value at '{}' was already set", cursor), - FieldError::Empty - => writeln!(f, "Field names must not be empty."), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError(String, String, String, String), - UnknownParameter(String, Vec<&'static str>), - InvalidUploadProtocol(String, Vec), - InvalidKeyValueSyntax(String, bool), - Input(InputError), - Field(FieldError), - MissingCommandError, - MissingMethodError(String), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let suffix = - match did_you_mean(param_name, &possible_values) { - Some(v) => format!(" Did you mean '{}' ?", v), - None => String::new(), - }; - write!(f, "Parameter '{}' is unknown.{}\n", param_name, suffix) - }, - CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { - let hashmap_info = if is_hashmap { "hashmap " } else { "" }; - writeln!(f, "'{}' does not match {}pattern =.", kv, hashmap_info) - }, - CLIError::MissingCommandError => writeln!(f, "Please specify the main sub-command."), - CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the '{}' command.", cmd), - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, - json_console_secret: &str) - -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::Io( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret - = json::from_str(json_console_secret).unwrap(); - match json::to_writer_pretty(&mut f, &console_secret) { - Err(serde_err) => match serde_err { - json::Error::Io(err) => err, - _ => panic!("Unexpected serde error: {:#?}", serde_err) - }, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(f) => { - match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::Io(err)) => - return secret_io_error(err), - Err(json_err) => - return Err(CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::DecoderError( - (secret_str(), json_err) - )))), - Ok(console_secret) => - match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} diff --git a/gen/toolresults1_beta3-cli/src/main.rs b/gen/toolresults1_beta3-cli/src/main.rs deleted file mode 100644 index f0e10aa977..0000000000 --- a/gen/toolresults1_beta3-cli/src/main.rs +++ /dev/null @@ -1,2064 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -#[macro_use] -extern crate clap; -extern crate yup_oauth2 as oauth2; -extern crate yup_hyper_mock as mock; -extern crate serde; -extern crate serde_json; -extern crate hyper; -extern crate mime; -extern crate strsim; -extern crate google_toolresults1_beta3 as api; - -use std::env; -use std::io::{self, Write}; -use clap::{App, SubCommand, Arg}; - -mod cmn; - -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol, - calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, FlowType}; -use serde_json as json; -use clap::ArgMatches; - -enum DoitError { - IoError(String, io::Error), - ApiError(api::Error), -} - -struct Engine<'n> { - opt: ArgMatches<'n>, - hub: api::ToolResults>, - gp: Vec<&'static str>, - gpm: Vec<(&'static str, &'static str)>, -} - - -impl<'n> Engine<'n> { - fn _projects_get_settings(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.projects().get_settings(opt.value_of("project-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_create(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "history-id" => Some(("historyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["display-name", "history-id", "name"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::History = json::value::from_value(object).unwrap(); - let mut call = self.hub.projects().histories_create(request, opt.value_of("project-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "request-id" => { - call = call.request_id(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["request-id"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_executions_create(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "test-execution-matrix-id" => Some(("testExecutionMatrixId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-time.nanos" => Some(("creationTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "creation-time.seconds" => Some(("creationTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "execution-id" => Some(("executionId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "completion-time.nanos" => Some(("completionTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "completion-time.seconds" => Some(("completionTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.infrastructure-failure" => Some(("outcome.inconclusiveDetail.infrastructureFailure", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.native-crash" => Some(("outcome.inconclusiveDetail.nativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.aborted-by-user" => Some(("outcome.inconclusiveDetail.abortedByUser", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-app-version" => Some(("outcome.skippedDetail.incompatibleAppVersion", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-architecture" => Some(("outcome.skippedDetail.incompatibleArchitecture", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-device" => Some(("outcome.skippedDetail.incompatibleDevice", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.success-detail.other-native-crash" => Some(("outcome.successDetail.otherNativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.other-native-crash" => Some(("outcome.failureDetail.otherNativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.crashed" => Some(("outcome.failureDetail.crashed", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.not-installed" => Some(("outcome.failureDetail.notInstalled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.timed-out" => Some(("outcome.failureDetail.timedOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.summary" => Some(("outcome.summary", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["aborted-by-user", "completion-time", "crashed", "creation-time", "execution-id", "failure-detail", "incompatible-app-version", "incompatible-architecture", "incompatible-device", "inconclusive-detail", "infrastructure-failure", "nanos", "native-crash", "not-installed", "other-native-crash", "outcome", "seconds", "skipped-detail", "state", "success-detail", "summary", "test-execution-matrix-id", "timed-out"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Execution = json::value::from_value(object).unwrap(); - let mut call = self.hub.projects().histories_executions_create(request, opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "request-id" => { - call = call.request_id(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["request-id"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_executions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.projects().histories_executions_get(opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or(""), opt.value_of("execution-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_executions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.projects().histories_executions_list(opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "page-size" => { - call = call.page_size(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["page-token", "page-size"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_executions_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "test-execution-matrix-id" => Some(("testExecutionMatrixId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-time.nanos" => Some(("creationTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "creation-time.seconds" => Some(("creationTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "execution-id" => Some(("executionId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "completion-time.nanos" => Some(("completionTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "completion-time.seconds" => Some(("completionTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.infrastructure-failure" => Some(("outcome.inconclusiveDetail.infrastructureFailure", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.native-crash" => Some(("outcome.inconclusiveDetail.nativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.aborted-by-user" => Some(("outcome.inconclusiveDetail.abortedByUser", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-app-version" => Some(("outcome.skippedDetail.incompatibleAppVersion", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-architecture" => Some(("outcome.skippedDetail.incompatibleArchitecture", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-device" => Some(("outcome.skippedDetail.incompatibleDevice", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.success-detail.other-native-crash" => Some(("outcome.successDetail.otherNativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.other-native-crash" => Some(("outcome.failureDetail.otherNativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.crashed" => Some(("outcome.failureDetail.crashed", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.not-installed" => Some(("outcome.failureDetail.notInstalled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.timed-out" => Some(("outcome.failureDetail.timedOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.summary" => Some(("outcome.summary", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["aborted-by-user", "completion-time", "crashed", "creation-time", "execution-id", "failure-detail", "incompatible-app-version", "incompatible-architecture", "incompatible-device", "inconclusive-detail", "infrastructure-failure", "nanos", "native-crash", "not-installed", "other-native-crash", "outcome", "seconds", "skipped-detail", "state", "success-detail", "summary", "test-execution-matrix-id", "timed-out"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Execution = json::value::from_value(object).unwrap(); - let mut call = self.hub.projects().histories_executions_patch(request, opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or(""), opt.value_of("execution-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "request-id" => { - call = call.request_id(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["request-id"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_executions_steps_create(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "test-execution-step.test-timing.test-process-duration.nanos" => Some(("testExecutionStep.testTiming.testProcessDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "test-execution-step.test-timing.test-process-duration.seconds" => Some(("testExecutionStep.testTiming.testProcessDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "test-execution-step.tool-execution.exit-code.number" => Some(("testExecutionStep.toolExecution.exitCode.number", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "test-execution-step.tool-execution.command-line-arguments" => Some(("testExecutionStep.toolExecution.commandLineArguments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "step-id" => Some(("stepId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "run-duration.nanos" => Some(("runDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "run-duration.seconds" => Some(("runDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-time.nanos" => Some(("creationTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "creation-time.seconds" => Some(("creationTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tool-execution-step.tool-execution.exit-code.number" => Some(("toolExecutionStep.toolExecution.exitCode.number", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "tool-execution-step.tool-execution.command-line-arguments" => Some(("toolExecutionStep.toolExecution.commandLineArguments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "completion-time.nanos" => Some(("completionTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "completion-time.seconds" => Some(("completionTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.infrastructure-failure" => Some(("outcome.inconclusiveDetail.infrastructureFailure", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.native-crash" => Some(("outcome.inconclusiveDetail.nativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.aborted-by-user" => Some(("outcome.inconclusiveDetail.abortedByUser", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-app-version" => Some(("outcome.skippedDetail.incompatibleAppVersion", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-architecture" => Some(("outcome.skippedDetail.incompatibleArchitecture", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-device" => Some(("outcome.skippedDetail.incompatibleDevice", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.success-detail.other-native-crash" => Some(("outcome.successDetail.otherNativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.other-native-crash" => Some(("outcome.failureDetail.otherNativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.crashed" => Some(("outcome.failureDetail.crashed", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.not-installed" => Some(("outcome.failureDetail.notInstalled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.timed-out" => Some(("outcome.failureDetail.timedOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.summary" => Some(("outcome.summary", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "device-usage-duration.nanos" => Some(("deviceUsageDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "device-usage-duration.seconds" => Some(("deviceUsageDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "has-images" => Some(("hasImages", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["aborted-by-user", "command-line-arguments", "completion-time", "crashed", "creation-time", "description", "device-usage-duration", "exit-code", "failure-detail", "has-images", "incompatible-app-version", "incompatible-architecture", "incompatible-device", "inconclusive-detail", "infrastructure-failure", "name", "nanos", "native-crash", "not-installed", "number", "other-native-crash", "outcome", "run-duration", "seconds", "skipped-detail", "state", "step-id", "success-detail", "summary", "test-execution-step", "test-process-duration", "test-timing", "timed-out", "tool-execution", "tool-execution-step"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Step = json::value::from_value(object).unwrap(); - let mut call = self.hub.projects().histories_executions_steps_create(request, opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or(""), opt.value_of("execution-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "request-id" => { - call = call.request_id(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["request-id"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_executions_steps_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.projects().histories_executions_steps_get(opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or(""), opt.value_of("execution-id").unwrap_or(""), opt.value_of("step-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_executions_steps_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.projects().histories_executions_steps_list(opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or(""), opt.value_of("execution-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "page-size" => { - call = call.page_size(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["page-token", "page-size"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_executions_steps_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - "test-execution-step.test-timing.test-process-duration.nanos" => Some(("testExecutionStep.testTiming.testProcessDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "test-execution-step.test-timing.test-process-duration.seconds" => Some(("testExecutionStep.testTiming.testProcessDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "test-execution-step.tool-execution.exit-code.number" => Some(("testExecutionStep.toolExecution.exitCode.number", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "test-execution-step.tool-execution.command-line-arguments" => Some(("testExecutionStep.toolExecution.commandLineArguments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "step-id" => Some(("stepId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "run-duration.nanos" => Some(("runDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "run-duration.seconds" => Some(("runDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-time.nanos" => Some(("creationTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "creation-time.seconds" => Some(("creationTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "tool-execution-step.tool-execution.exit-code.number" => Some(("toolExecutionStep.toolExecution.exitCode.number", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "tool-execution-step.tool-execution.command-line-arguments" => Some(("toolExecutionStep.toolExecution.commandLineArguments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "completion-time.nanos" => Some(("completionTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "completion-time.seconds" => Some(("completionTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.infrastructure-failure" => Some(("outcome.inconclusiveDetail.infrastructureFailure", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.native-crash" => Some(("outcome.inconclusiveDetail.nativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.inconclusive-detail.aborted-by-user" => Some(("outcome.inconclusiveDetail.abortedByUser", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-app-version" => Some(("outcome.skippedDetail.incompatibleAppVersion", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-architecture" => Some(("outcome.skippedDetail.incompatibleArchitecture", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.skipped-detail.incompatible-device" => Some(("outcome.skippedDetail.incompatibleDevice", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.success-detail.other-native-crash" => Some(("outcome.successDetail.otherNativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.other-native-crash" => Some(("outcome.failureDetail.otherNativeCrash", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.crashed" => Some(("outcome.failureDetail.crashed", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.not-installed" => Some(("outcome.failureDetail.notInstalled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.failure-detail.timed-out" => Some(("outcome.failureDetail.timedOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "outcome.summary" => Some(("outcome.summary", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "device-usage-duration.nanos" => Some(("deviceUsageDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "device-usage-duration.seconds" => Some(("deviceUsageDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "has-images" => Some(("hasImages", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["aborted-by-user", "command-line-arguments", "completion-time", "crashed", "creation-time", "description", "device-usage-duration", "exit-code", "failure-detail", "has-images", "incompatible-app-version", "incompatible-architecture", "incompatible-device", "inconclusive-detail", "infrastructure-failure", "name", "nanos", "native-crash", "not-installed", "number", "other-native-crash", "outcome", "run-duration", "seconds", "skipped-detail", "state", "step-id", "success-detail", "summary", "test-execution-step", "test-process-duration", "test-timing", "timed-out", "tool-execution", "tool-execution-step"]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::Step = json::value::from_value(object).unwrap(); - let mut call = self.hub.projects().histories_executions_steps_patch(request, opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or(""), opt.value_of("execution-id").unwrap_or(""), opt.value_of("step-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "request-id" => { - call = call.request_id(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["request-id"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_executions_steps_publish_xunit_xml_files(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - - let mut field_cursor = FieldCursor::default(); - let mut object = json::value::Value::Object(Default::default()); - - for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let last_errc = err.issues.len(); - let (key, value) = parse_kv_arg(&*kvarg, err, false); - let mut temp_cursor = field_cursor.clone(); - if let Err(field_err) = temp_cursor.set(&*key) { - err.issues.push(field_err); - } - if value.is_none() { - field_cursor = temp_cursor.clone(); - if err.issues.len() > last_errc { - err.issues.remove(last_errc); - } - continue; - } - - let type_info: Option<(&'static str, JsonTypeInfo)> = - match &temp_cursor.to_string()[..] { - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec![]); - err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); - None - } - }; - if let Some((field_cursor_str, type_info)) = type_info { - FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor); - } - } - let mut request: api::PublishXunitXmlFilesRequest = json::value::from_value(object).unwrap(); - let mut call = self.hub.projects().histories_executions_steps_publish_xunit_xml_files(request, opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or(""), opt.value_of("execution-id").unwrap_or(""), opt.value_of("step-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_executions_steps_thumbnails_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.projects().histories_executions_steps_thumbnails_list(opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or(""), opt.value_of("execution-id").unwrap_or(""), opt.value_of("step-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "page-size" => { - call = call.page_size(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["page-token", "page-size"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.projects().histories_get(opt.value_of("project-id").unwrap_or(""), opt.value_of("history-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_histories_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.projects().histories_list(opt.value_of("project-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "page-size" => { - call = call.page_size(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); - }, - "filter-by-name" => { - call = call.filter_by_name(value.unwrap_or("")); - }, - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v.extend(["page-token", "filter-by-name", "page-size"].iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _projects_initialize_settings(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut call = self.hub.projects().initialize_settings(opt.value_of("project-id").unwrap_or("")); - for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - let (key, value) = parse_kv_arg(&*parg, err, false); - match key { - _ => { - let mut found = false; - for param in &self.gp { - if key == *param { - found = true; - call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); - break; - } - } - if !found { - err.issues.push(CLIError::UnknownParameter(key.to_string(), - {let mut v = Vec::new(); - v.extend(self.gp.iter().map(|v|*v)); - v } )); - } - } - } - } - let protocol = CallType::Standard; - if dry_run { - Ok(()) - } else { - assert!(err.issues.len() == 0); - for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { - call = call.add_scope(scope); - } - let mut ostream = match writer_from_opts(opt.value_of("out")) { - Ok(mut f) => f, - Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), - }; - match match protocol { - CallType::Standard => call.doit(), - _ => unreachable!() - } { - Err(api_err) => Err(DoitError::ApiError(api_err)), - Ok((mut response, output_schema)) => { - let mut value = json::value::to_value(&output_schema); - remove_json_null_values(&mut value); - json::to_writer_pretty(&mut ostream, &value).unwrap(); - ostream.flush().unwrap(); - Ok(()) - } - } - } - } - - fn _doit(&self, dry_run: bool) -> Result, Option> { - let mut err = InvalidOptionsError::new(); - let mut call_result: Result<(), DoitError> = Ok(()); - let mut err_opt: Option = None; - match self.opt.subcommand() { - ("projects", Some(opt)) => { - match opt.subcommand() { - ("get-settings", Some(opt)) => { - call_result = self._projects_get_settings(opt, dry_run, &mut err); - }, - ("histories-create", Some(opt)) => { - call_result = self._projects_histories_create(opt, dry_run, &mut err); - }, - ("histories-executions-create", Some(opt)) => { - call_result = self._projects_histories_executions_create(opt, dry_run, &mut err); - }, - ("histories-executions-get", Some(opt)) => { - call_result = self._projects_histories_executions_get(opt, dry_run, &mut err); - }, - ("histories-executions-list", Some(opt)) => { - call_result = self._projects_histories_executions_list(opt, dry_run, &mut err); - }, - ("histories-executions-patch", Some(opt)) => { - call_result = self._projects_histories_executions_patch(opt, dry_run, &mut err); - }, - ("histories-executions-steps-create", Some(opt)) => { - call_result = self._projects_histories_executions_steps_create(opt, dry_run, &mut err); - }, - ("histories-executions-steps-get", Some(opt)) => { - call_result = self._projects_histories_executions_steps_get(opt, dry_run, &mut err); - }, - ("histories-executions-steps-list", Some(opt)) => { - call_result = self._projects_histories_executions_steps_list(opt, dry_run, &mut err); - }, - ("histories-executions-steps-patch", Some(opt)) => { - call_result = self._projects_histories_executions_steps_patch(opt, dry_run, &mut err); - }, - ("histories-executions-steps-publish-xunit-xml-files", Some(opt)) => { - call_result = self._projects_histories_executions_steps_publish_xunit_xml_files(opt, dry_run, &mut err); - }, - ("histories-executions-steps-thumbnails-list", Some(opt)) => { - call_result = self._projects_histories_executions_steps_thumbnails_list(opt, dry_run, &mut err); - }, - ("histories-get", Some(opt)) => { - call_result = self._projects_histories_get(opt, dry_run, &mut err); - }, - ("histories-list", Some(opt)) => { - call_result = self._projects_histories_list(opt, dry_run, &mut err); - }, - ("initialize-settings", Some(opt)) => { - call_result = self._projects_initialize_settings(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("projects".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, - _ => { - err.issues.push(CLIError::MissingCommandError); - writeln!(io::stderr(), "{}\n", self.opt.usage()).ok(); - } - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - Err(err_opt) - } else { - Ok(call_result) - } - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: ArgMatches<'n>) -> Result, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "toolresults1-beta3-secret.json", - "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, - if opt.is_present("debug-auth") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }, - JsonTokenStorage { - program_name: "toolresults1-beta3", - db_dir: config_dir.clone(), - }, Some(FlowType::InstalledInteractive)); - - let client = - if opt.is_present("debug") { - hyper::Client::with_connector(mock::TeeConnector { - connector: hyper::net::HttpsConnector::::default() - }) - } else { - hyper::Client::new() - }; - let engine = Engine { - opt: opt, - hub: api::ToolResults::new(client, auth), - gp: vec!["alt", "fields", "key", "oauth-token", "pretty-print", "quota-user", "user-ip"], - gpm: vec![ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ] - }; - - match engine._doit(true) { - Err(Some(err)) => Err(err), - Err(None) => Ok(engine), - Ok(_) => unreachable!(), - } - } - - fn doit(&self) -> Result<(), DoitError> { - match self._doit(false) { - Ok(res) => res, - Err(_) => unreachable!(), - } - } -} - -fn main() { - let mut exit_status = 0i32; - let arg_data = [ - ("projects", "methods: 'get-settings', 'histories-create', 'histories-executions-create', 'histories-executions-get', 'histories-executions-list', 'histories-executions-patch', 'histories-executions-steps-create', 'histories-executions-steps-get', 'histories-executions-steps-list', 'histories-executions-steps-patch', 'histories-executions-steps-publish-xunit-xml-files', 'histories-executions-steps-thumbnails-list', 'histories-get', 'histories-list' and 'initialize-settings'", vec![ - ("get-settings", - Some(r##"Gets the Tool Results settings for a project. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to read from project"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_get-settings", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-create", - Some(r##"Creates a History. - - The returned History will have the id set. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the containing project does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-create", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-executions-create", - Some(r##"Creates an Execution. - - The returned Execution will have the id set. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the containing History does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-executions-create", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"A History id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-executions-get", - Some(r##"Gets an Execution. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the Execution does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-executions-get", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"A History id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"execution-id"##), - None, - Some(r##"An Execution id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-executions-list", - Some(r##"Lists Histories for a given Project. - - The executions are sorted by creation_time in descending order. The execution_id key will be used to order the executions with the same creation_time. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the containing History does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-executions-list", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"A History id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-executions-patch", - Some(r##"Updates an existing Execution with the supplied partial entity. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the requested state transition is illegal - NOT_FOUND - if the containing History does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-executions-patch", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"Required."##), - Some(true), - Some(false)), - - (Some(r##"execution-id"##), - None, - Some(r##"Required."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-executions-steps-create", - Some(r##"Creates a Step. - - The returned Step will have the id set. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the step is too large (more than 10Mib) - NOT_FOUND - if the containing Execution does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-executions-steps-create", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"A History id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"execution-id"##), - None, - Some(r##"A Execution id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-executions-steps-get", - Some(r##"Gets a Step. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the Step does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-executions-steps-get", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"A History id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"execution-id"##), - None, - Some(r##"A Execution id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"step-id"##), - None, - Some(r##"A Step id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-executions-steps-list", - Some(r##"Lists Steps for a given Execution. - - The steps are sorted by creation_time in descending order. The step_id key will be used to order the steps with the same creation_time. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if an argument in the request happens to be invalid; e.g. if an attempt is made to list the children of a nonexistent Step - NOT_FOUND - if the containing Execution does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-executions-steps-list", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"A History id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"execution-id"##), - None, - Some(r##"A Execution id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-executions-steps-patch", - Some(r##"Updates an existing Step with the supplied partial entity. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to write project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the requested state transition is illegal (e.g try to upload a duplicate xml file), if the updated step is too large (more than 10Mib) - NOT_FOUND - if the containing Execution does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-executions-steps-patch", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"A History id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"execution-id"##), - None, - Some(r##"A Execution id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"step-id"##), - None, - Some(r##"A Step id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-executions-steps-publish-xunit-xml-files", - Some(r##"Publish xml files to an existing Step. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to write project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the requested state transition is illegal, e.g try to upload a duplicate xml file or a file too large. - NOT_FOUND - if the containing Execution does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-executions-steps-publish-xunit-xml-files", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"A History id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"execution-id"##), - None, - Some(r##"A Execution id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"step-id"##), - None, - Some(r##"A Step id. Note: This step must include a TestExecutionStep. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"kv"##), - Some(r##"r"##), - Some(r##"Set various fields of the request structure, matching the key=value form"##), - Some(true), - Some(true)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-executions-steps-thumbnails-list", - Some(r##"Lists thumbnails of images attached to a step. - - May return any of the following canonical error codes: - PERMISSION_DENIED - if the user is not authorized to read from the project, or from any of the images - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the step does not exist, or if any of the images do not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-executions-steps-thumbnails-list", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"A History id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"execution-id"##), - None, - Some(r##"An Execution id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"step-id"##), - None, - Some(r##"A Step id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-get", - Some(r##"Gets a History. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the History does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-get", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"history-id"##), - None, - Some(r##"A History id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("histories-list", - Some(r##"Lists Histories for a given Project. - - The histories are sorted by modification time in descending order. The history_id key will be used to order the history with the same modification time. - - May return any of the following canonical error codes: - - - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the History does not exist"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_histories-list", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ("initialize-settings", - Some(r##"Creates resources for settings which have not yet been set. - - Currently, this creates a single resource: a Google Cloud Storage bucket, to be used as the default bucket for this project. The bucket is created in the name of the user calling. Except in rare cases, calling this method in parallel from multiple clients will only create a single bucket. In order to avoid unnecessary storage charges, the bucket is configured to automatically delete objects older than 90 days. - - The bucket is created with the project-private ACL: All project team members are given permissions to the bucket and objects created within it according to their roles. Project owners have owners rights, and so on. The default ACL on objects created in the bucket is project-private as well. See Google Cloud Storage documentation for more details. - - If there is already a default bucket set and the project can access the bucket, this call does nothing. However, if the project doesn't have the permission to access the bucket or the bucket is deteleted, a new bucket will be created. - - May return any canonical error codes, including the following: - - - PERMISSION_DENIED - if the user is not authorized to write to project - Any error code raised by Google Cloud Storage"##), - "Details at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli/projects_initialize-settings", - vec![ - (Some(r##"project-id"##), - None, - Some(r##"A Project id. - - Required."##), - Some(true), - Some(false)), - - (Some(r##"v"##), - Some(r##"p"##), - Some(r##"Set various optional parameters, matching the key=value form"##), - Some(false), - Some(true)), - - (Some(r##"out"##), - Some(r##"o"##), - Some(r##"Specify the file into which to write the program's output"##), - Some(false), - Some(false)), - ]), - ]), - - ]; - - let mut app = App::new("toolresults1-beta3") - .author("Sebastian Thiel ") - .version("0.3.5+20160408") - .about("Read and publish results from Cloud Test Lab.") - .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_toolresults1_beta3_cli") - .arg(Arg::with_name("url") - .long("scope") - .help("Specify the authentication a method should be executed in. Each scope requires the user to grant this application permission to use it.If unset, it defaults to the shortest scope url for a particular method.") - .multiple(true) - .takes_value(true)) - .arg(Arg::with_name("folder") - .long("config-dir") - .help("A directory into which we will store our persistent data. Defaults to a user-writable directory that we will create during the first invocation.[default: ~/.google-service-cli") - .multiple(false) - .takes_value(true)) - .arg(Arg::with_name("debug") - .long("debug") - .help("Output all server communication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)) - .arg(Arg::with_name("debug-auth") - .long("debug-auth") - .help("Output all communication related to authentication to standard error. `tx` and `rx` are placed into the same stream.") - .multiple(false) - .takes_value(false)); - - for &(main_command_name, about, ref subcommands) in arg_data.iter() { - let mut mcmd = SubCommand::with_name(main_command_name).about(about); - - for &(sub_command_name, ref desc, url_info, ref args) in subcommands { - let mut scmd = SubCommand::with_name(sub_command_name); - if let &Some(desc) = desc { - scmd = scmd.about(desc); - } - scmd = scmd.after_help(url_info); - - for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args { - let arg_name_str = - match (arg_name, flag) { - (&Some(an), _ ) => an, - (_ , &Some(f)) => f, - _ => unreachable!(), - }; - let mut arg = Arg::with_name(arg_name_str) - .empty_values(false); - if let &Some(short_flag) = flag { - arg = arg.short(short_flag); - } - if let &Some(desc) = desc { - arg = arg.help(desc); - } - if arg_name.is_some() && flag.is_some() { - arg = arg.takes_value(true); - } - if let &Some(required) = required { - arg = arg.required(required); - } - if let &Some(multi) = multi { - arg = arg.multiple(multi); - } - scmd = scmd.arg(arg); - } - mcmd = mcmd.subcommand(scmd); - } - app = app.subcommand(mcmd); - } - - let matches = app.get_matches(); - - let debug = matches.is_present("debug"); - match Engine::new(matches) { - Err(err) => { - exit_status = err.exit_code; - writeln!(io::stderr(), "{}", err).ok(); - }, - Ok(engine) => { - if let Err(doit_err) = engine.doit() { - exit_status = 1; - match doit_err { - DoitError::IoError(path, err) => { - writeln!(io::stderr(), "Failed to open output file '{}': {}", path, err).ok(); - }, - DoitError::ApiError(err) => { - if debug { - writeln!(io::stderr(), "{:#?}", err).ok(); - } else { - writeln!(io::stderr(), "{}", err).ok(); - } - } - } - } - } - } - - std::process::exit(exit_status); -} \ No newline at end of file diff --git a/gen/toolresults1_beta3/Cargo.toml b/gen/toolresults1_beta3/Cargo.toml deleted file mode 100644 index b49202084b..0000000000 --- a/gen/toolresults1_beta3/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-toolresults1_beta3" -version = "0.1.14+20160408" -authors = ["Sebastian Thiel "] -description = "A complete library to interact with Tool Results (protocol v1beta3)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/toolresults1_beta3" -homepage = "https://developers.google.com/cloud-test-lab/" -documentation = "http://byron.github.io/google-apis-rs/google_toolresults1_beta3" -license = "MIT" -keywords = ["toolresults", "google", "protocol", "web", "api"] -build = "src/build.rs" - - -[dependencies] -hyper = "^ 0.9" -mime = "^ 0.2.0" -serde = "^ 0.7.5" -serde_json = "^ 0.7.0" -yup-oauth2 = { version = "^ 0.6.0", optional = true, default-features = false } -serde_macros = { version = "^ 0.7.5", optional = true } -url = "= 0.5" - -[features] -default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly"] -with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen"] - -[build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } - diff --git a/gen/toolresults1_beta3/LICENSE.md b/gen/toolresults1_beta3/LICENSE.md deleted file mode 100644 index ff523b4547..0000000000 --- a/gen/toolresults1_beta3/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015-2016` `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. diff --git a/gen/toolresults1_beta3/README.md b/gen/toolresults1_beta3/README.md deleted file mode 100644 index f081b91914..0000000000 --- a/gen/toolresults1_beta3/README.md +++ /dev/null @@ -1,183 +0,0 @@ - -The `google-toolresults1_beta3` library allows access to all features of the *Google Tool Results* service. - -This documentation was generated from *Tool Results* crate version *0.1.14+20160408*, where *20160408* is the exact revision of the *toolresults:v1beta3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. - -Everything else about the *Tool Results* *v1_beta3* API can be found at the -[official documentation site](https://developers.google.com/cloud-test-lab/). -# Features - -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ToolResults.html) ... - -* projects - * [*get settings*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectGetSettingCall.html), [*histories create*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryCreateCall.html), [*histories executions create*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryExecutionCreateCall.html), [*histories executions get*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryExecutionGetCall.html), [*histories executions list*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryExecutionListCall.html), [*histories executions patch*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryExecutionPatchCall.html), [*histories executions steps create*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryExecutionStepCreateCall.html), [*histories executions steps get*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryExecutionStepGetCall.html), [*histories executions steps list*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryExecutionStepListCall.html), [*histories executions steps patch*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryExecutionStepPatchCall.html), [*histories executions steps publish xunit xml files*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryExecutionStepPublishXunitXmlFileCall.html), [*histories executions steps thumbnails list*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryExecutionStepThumbnailListCall.html), [*histories get*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryGetCall.html), [*histories list*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectHistoryListCall.html) and [*initialize settings*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ProjectInitializeSettingCall.html) - - - - -# Structure of this Library - -The API is structured into the following primary items: - -* **[Hub](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/struct.ToolResults.html)** - * a central object to maintain state and allow accessing all *Activities* - * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.MethodsBuilder.html) which in turn - allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.CallBuilder.html) -* **[Resources](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.Resource.html)** - * primary types that you can apply *Activities* to - * a collection of properties and *Parts* - * **[Parts](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.Part.html)** - * a collection of properties - * never directly used in *Activities* -* **[Activities](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.CallBuilder.html)** - * 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() -``` - -Or specifically ... - -```ignore -let r = hub.projects().histories_executions_steps_patch(...).doit() -let r = hub.projects().histories_executions_steps_get(...).doit() -let r = hub.projects().histories_executions_steps_publish_xunit_xml_files(...).doit() -let r = hub.projects().histories_executions_steps_create(...).doit() -``` - -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-toolresults1_beta3 = "*" -``` - -## A complete example - -```Rust -extern crate hyper; -extern crate yup_oauth2 as oauth2; -extern crate google_toolresults1_beta3 as toolresults1_beta3; -use toolresults1_beta3::Step; -use toolresults1_beta3::{Result, Error}; -use std::default::Default; -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use toolresults1_beta3::ToolResults; - -// Get an ApplicationSecret instance by some means. It contains the `client_id` and -// `client_secret`, among other things. -let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - ::default(), None); -let mut hub = ToolResults::new(hyper::Client::new(), 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 = Step::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.projects().histories_executions_steps_patch(req, "projectId", "historyId", "executionId", "stepId") - .request_id("et") - .doit(); - -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::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](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/enum.Result.html) enumeration as return value of -the doit() methods, or handed as possibly intermediate results to either the -[Hub Delegate](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/../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](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/enum.Result.html), should be -read by you to obtain the media. -If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.ResponseResult.html), 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](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.Delegate.html) to the -[Method Builder](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.CallBuilder.html) 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](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.Delegate.html) 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 [enocodable](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.RequestValue.html) and -[decodable](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -are valid. -Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.Part.html) 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](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.CallBuilder.html), 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](http://byron.github.io/google-apis-rs/google_toolresults1_beta3/trait.RequestValue.html) 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 **toolresults1_beta3** 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-rs/LICENSE.md diff --git a/gen/toolresults1_beta3/src/build.rs b/gen/toolresults1_beta3/src/build.rs deleted file mode 100644 index 0bebaf0bf0..0000000000 --- a/gen/toolresults1_beta3/src/build.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[cfg(feature = "with-serde-codegen")] -mod inner { - extern crate serde_codegen; - - use std::env; - use std::path::Path; - - pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - - let src = Path::new("src/lib.rs.in"); - let dst = Path::new(&out_dir).join("lib.rs"); - - serde_codegen::expand(&src, &dst).unwrap(); - } -} - -#[cfg(not(feature = "with-serde-codegen"))] -mod inner { - pub fn main() {} -} - -pub fn main() { - inner::main() -} \ No newline at end of file diff --git a/gen/toolresults1_beta3/src/cmn.rs b/gen/toolresults1_beta3/src/cmn.rs deleted file mode 100644 index d75063e466..0000000000 --- a/gen/toolresults1_beta3/src/cmn.rs +++ /dev/null @@ -1,753 +0,0 @@ -// COPY OF 'src/rust/api/cmn.rs' -// DO NOT EDIT -use std::io::{self, Read, Seek, Cursor, Write, SeekFrom}; -use std; -use std::fmt::{self, Display}; -use std::str::FromStr; -use std::error; -use std::thread::sleep; -use std::time::Duration; - -use mime::{Mime, TopLevel, SubLevel, Attr, Value}; -use oauth2::{TokenType, Retry, self}; -use hyper; -use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header, - HeaderFormat, Bearer}; -use hyper::http::h1::LINE_ENDING; -use hyper::method::Method; -use hyper::status::StatusCode; - -use serde_json as json; - -/// 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 {} -impl 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 utility type which can decode a server response that indicates error -#[derive(Deserialize)] -pub struct JsonServerError { - pub error: String, - pub error_description: Option -} - -/// A utility to represent detailed errors we might see in case there are BadRequests. -/// The latter happen if the sent parameters or request structures are unsound -#[derive(Deserialize, Serialize, Debug)] -pub struct ErrorResponse { - error: ServerError, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerError { - errors: Vec, - code: u16, - message: String, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct ServerMessage { - domain: String, - reason: String, - message: String, - #[serde(rename="locationType")] - location_type: Option, - location: Option -} - -#[derive(Copy, Clone)] -pub struct DummyNetworkStream; - -impl Read for DummyNetworkStream { - fn read(&mut self, _: &mut [u8]) -> io::Result { - Ok(0) - } -} - -impl Write for DummyNetworkStream { - fn write(&mut self, _: &[u8]) -> io::Result { - Ok(0) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl hyper::net::NetworkStream for DummyNetworkStream { - fn peer_addr(&mut self) -> io::Result { - Ok("127.0.0.1:1337".parse().unwrap()) - } - - fn set_read_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } - - fn set_write_timeout(&self, _dur: Option) -> io::Result<()> { - Ok(()) - } -} - - -/// 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 { - - /// 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, MethodInfo) {} - - /// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), 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, &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 { - 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: &error::Error) -> Option { - 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 { - 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::client::Response, Option, _: Option) -> 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(ErrorResponse), - - /// 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(Box), - - /// 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::client::Response), -} - - -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - 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 err) => { - try!(writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message)); - for err in err.error.errors.iter() { - try!(writeln!(f, " {}: {}, {}{}", - err.domain, - err.message, - err.reason, - match &err.location { - &Some(ref loc) => format!("@{}", loc), - &None => String::new(), - })); - } - 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 description(&self) -> &str { - match *self { - Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(_, ref err) => err.description(), - _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" - } - } - - fn cause(&self) -> Option<&error::Error> { - match *self { - Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(_, ref err) => err.cause(), - _ => None - } - } -} - -/// A universal result type used as return for all calls. -pub type Result = std::result::Result; - -/// Contains information about an API request. -pub struct MethodInfo { - pub id: &'static str, - pub http_method: Method, -} - -const BOUNDARY: &'static 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<(Headers, &'a mut Read)>, - current_part: Option<(Cursor>, &'a mut Read)>, - last_part_boundary: Option>>, -} - -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 Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> { - let mut headers = Headers::new(); - headers.set(ContentType(mime_type)); - headers.set(ContentLength(size)); - 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.len() == 0 && 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.len() == 0 && self.current_part.is_some() - } -} - -impl<'a> Read for MultiPartReader<'a> { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - 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::::new()); - (write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING, - headers, 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).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<'a>(&'a self) -> &'a Mime { &self.0 } -} -impl ::std::ops::DerefMut for XUploadContentType { - fn deref_mut<'a>(&'a mut self) -> &'a mut Mime { &mut self.0 } -} -impl Header for XUploadContentType { - fn header_name() -> &'static str { "X-Upload-Content-Type" } - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - hyper::header::parsing::from_one_raw_str(raw).map(XUploadContentType) - } -} -impl HeaderFormat for XUploadContentType { - fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&**self, f) - } -} -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 { - 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, - pub total_length: u64, -} - -impl Header for ContentRange { - fn header_name() -> &'static str { - "Content-Range" - } - - /// We are not parsable, as parsing is done by the `Range` header - fn parse_header(_: &[Vec]) -> hyper::error::Result { - Err(hyper::error::Error::Method) - } -} - - -impl HeaderFormat for ContentRange { - fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes ")); - match self.range { - Some(ref c) => try!(c.fmt(fmt)), - None => try!(fmt.write_str("*")) - } - (write!(fmt, "/{}", self.total_length)).ok(); - Ok(()) - } -} - -#[derive(Clone, PartialEq, Debug)] -pub struct RangeResponseHeader(pub Chunk); - -impl Header for RangeResponseHeader { - fn header_name() -> &'static str { - "Range" - } - - fn parse_header(raw: &[Vec]) -> hyper::error::Result { - if raw.len() > 0 { - let v = &raw[0]; - if let Ok(s) = std::str::from_utf8(v) { - const PREFIX: &'static str = "bytes "; - if s.starts_with(PREFIX) { - if let Ok(c) = ::from_str(&s[PREFIX.len()..]) { - return Ok(RangeResponseHeader(c)) - } - } - } - } - Err(hyper::error::Error::Method) - } -} - -impl HeaderFormat for RangeResponseHeader { - /// No implmentation necessary, we just need to parse - fn fmt_header(&self, _: &mut fmt::Formatter) -> fmt::Result { - Err(fmt::Error) - } -} - -/// A utility type to perform a resumable upload from start to end. -pub struct ResumableUploadHelper<'a, A: 'a> { - pub client: &'a mut hyper::client::Client, - pub delegate: &'a mut Delegate, - pub start_at: Option, - pub auth: &'a mut A, - pub user_agent: &'a str, - pub auth_header: Authorization, - pub url: &'a str, - pub reader: &'a mut ReadSeek, - pub media_type: Mime, - pub content_length: u64 -} - -impl<'a, A> ResumableUploadHelper<'a, A> - where A: oauth2::GetToken { - - fn query_transfer_status(&mut self) -> std::result::Result> { - loop { - match self.client.post(self.url) - .header(UserAgent(self.user_agent.to_string())) - .header(ContentRange { range: None, total_length: self.content_length }) - .header(self.auth_header.clone()) - .send() { - Ok(r) => { - // 308 = resume-incomplete == PermanentRedirect - let headers = r.headers.clone(); - let h: &RangeResponseHeader = match headers.get() { - Some(hh) if r.status == StatusCode::PermanentRedirect => hh, - None|Some(_) => { - if let Retry::After(d) = self.delegate.http_failure(&r, None, 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 fn upload(&mut self) -> Option> { - let mut start = match self.start_at { - Some(s) => s, - None => match self.query_transfer_status() { - 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 - }; - - self.reader.seek(SeekFrom::Start(start)).unwrap(); - loop { - 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 range_header = ContentRange { - range: Some(Chunk {first: start, last: start + request_size - 1}), - total_length: self.content_length - }; - start += request_size; - if self.delegate.cancel_chunk_upload(&range_header) { - return None - } - let res = self.client.post(self.url) - .header(range_header) - .header(ContentType(self.media_type.clone())) - .header(UserAgent(self.user_agent.to_string())) - .body(&mut section_reader) - .send(); - match res { - Ok(mut res) => { - if res.status == StatusCode::PermanentRedirect { - continue - } - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let Retry::After(d) = self.delegate.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - } - return Some(Ok(res)) - }, - Err(err) => { - if let Retry::After(d) = self.delegate.http_error(&err) { - sleep(d); - continue; - } - return Some(Err(err)) - } - } - } - } -} - -// Copy of src/rust/cli/cmn.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); - } - } - _ => {} - } -} diff --git a/gen/toolresults1_beta3/src/lib.rs b/gen/toolresults1_beta3/src/lib.rs deleted file mode 100644 index de375100c5..0000000000 --- a/gen/toolresults1_beta3/src/lib.rs +++ /dev/null @@ -1,193 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.mako' -// DO NOT EDIT ! - -//! This documentation was generated from *Tool Results* crate version *0.1.14+20160408*, where *20160408* is the exact revision of the *toolresults:v1beta3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. -//! -//! Everything else about the *Tool Results* *v1_beta3* API can be found at the -//! [official documentation site](https://developers.google.com/cloud-test-lab/). -//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/toolresults1_beta3). -//! # Features -//! -//! Handle the following *Resources* with ease from the central [hub](struct.ToolResults.html) ... -//! -//! * projects -//! * [*get settings*](struct.ProjectGetSettingCall.html), [*histories create*](struct.ProjectHistoryCreateCall.html), [*histories executions create*](struct.ProjectHistoryExecutionCreateCall.html), [*histories executions get*](struct.ProjectHistoryExecutionGetCall.html), [*histories executions list*](struct.ProjectHistoryExecutionListCall.html), [*histories executions patch*](struct.ProjectHistoryExecutionPatchCall.html), [*histories executions steps create*](struct.ProjectHistoryExecutionStepCreateCall.html), [*histories executions steps get*](struct.ProjectHistoryExecutionStepGetCall.html), [*histories executions steps list*](struct.ProjectHistoryExecutionStepListCall.html), [*histories executions steps patch*](struct.ProjectHistoryExecutionStepPatchCall.html), [*histories executions steps publish xunit xml files*](struct.ProjectHistoryExecutionStepPublishXunitXmlFileCall.html), [*histories executions steps thumbnails list*](struct.ProjectHistoryExecutionStepThumbnailListCall.html), [*histories get*](struct.ProjectHistoryGetCall.html), [*histories list*](struct.ProjectHistoryListCall.html) and [*initialize settings*](struct.ProjectInitializeSettingCall.html) -//! -//! -//! -//! -//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html). -//! -//! # Structure of this Library -//! -//! The API is structured into the following primary items: -//! -//! * **[Hub](struct.ToolResults.html)** -//! * a central object to maintain state and allow accessing all *Activities* -//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn -//! allow access to individual [*Call Builders*](trait.CallBuilder.html) -//! * **[Resources](trait.Resource.html)** -//! * primary types that you can apply *Activities* to -//! * a collection of properties and *Parts* -//! * **[Parts](trait.Part.html)** -//! * a collection of properties -//! * never directly used in *Activities* -//! * **[Activities](trait.CallBuilder.html)** -//! * 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() -//! ``` -//! -//! Or specifically ... -//! -//! ```ignore -//! let r = hub.projects().histories_executions_steps_patch(...).doit() -//! let r = hub.projects().histories_executions_steps_get(...).doit() -//! let r = hub.projects().histories_executions_steps_publish_xunit_xml_files(...).doit() -//! let r = hub.projects().histories_executions_steps_create(...).doit() -//! ``` -//! -//! 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-toolresults1_beta3 = "*" -//! ``` -//! -//! ## A complete example -//! -//! ```test_harness,no_run -//! extern crate hyper; -//! extern crate yup_oauth2 as oauth2; -//! extern crate google_toolresults1_beta3 as toolresults1_beta3; -//! use toolresults1_beta3::Step; -//! use toolresults1_beta3::{Result, Error}; -//! # #[test] fn egal() { -//! use std::default::Default; -//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use toolresults1_beta3::ToolResults; -//! -//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and -//! // `client_secret`, among other things. -//! let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -//! hyper::Client::new(), -//! ::default(), None); -//! let mut hub = ToolResults::new(hyper::Client::new(), 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 = Step::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.projects().histories_executions_steps_patch(req, "projectId", "historyId", "executionId", "stepId") -//! .request_id("amet.") -//! .doit(); -//! -//! 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::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](enum.Result.html) enumeration as return value of -//! the doit() methods, or handed as possibly intermediate results to either the -//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../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](enum.Result.html), should be -//! read by you to obtain the media. -//! If such a method also supports a [Response Result](trait.ResponseResult.html), 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](trait.Delegate.html) to the -//! [Method Builder](trait.CallBuilder.html) 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](trait.Delegate.html) 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 [enocodable](trait.RequestValue.html) and -//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -//! are valid. -//! Most optionals are are considered [Parts](trait.Part.html) 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](trait.CallBuilder.html), 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](trait.RequestValue.html) 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 ... . -#![cfg_attr(feature = "nightly", feature(custom_derive, custom_attribute, plugin))] -#![cfg_attr(feature = "nightly", plugin(serde_macros))] -#![allow(unused_imports, unused_mut, dead_code)] - -#[cfg(feature = "nightly")] -include!("lib.rs.in"); - -#[cfg(feature = "with-serde-codegen")] -include!(concat!(env!("OUT_DIR"), "/lib.rs")); \ No newline at end of file diff --git a/gen/toolresults1_beta3/src/lib.rs.in b/gen/toolresults1_beta3/src/lib.rs.in deleted file mode 100644 index cc67dfa347..0000000000 --- a/gen/toolresults1_beta3/src/lib.rs.in +++ /dev/null @@ -1,6009 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.in.mako' -// DO NOT EDIT ! - -extern crate hyper; -extern crate serde; -extern crate serde_json; -extern crate yup_oauth2 as oauth2; -extern crate mime; -extern crate url; - -mod cmn; - -use std::collections::HashMap; -use std::cell::RefCell; -use std::borrow::BorrowMut; -use std::default::Default; -use std::collections::BTreeMap; -use serde_json as json; -use std::io; -use std::fs; -use std::thread::sleep; -use std::time::Duration; - -pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, - ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, - Resource, ErrorResponse, remove_json_null_values}; - - -// ############## -// UTILITIES ### -// ############ - -/// Identifies the an OAuth2 authorization scope. -/// A scope is needed when requesting an -/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). -#[derive(PartialEq, Eq, Hash)] -pub enum Scope { - /// View and manage your data across Google Cloud Platform services - CloudPlatform, -} - -impl AsRef for Scope { - fn as_ref(&self) -> &str { - match *self { - Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform", - } - } -} - -impl Default for Scope { - fn default() -> Scope { - Scope::CloudPlatform - } -} - - - -// ######## -// HUB ### -// ###### - -/// Central instance to access all ToolResults related resource activities -/// -/// # Examples -/// -/// Instantiate a new hub -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// use toolresults1_beta3::Step; -/// use toolresults1_beta3::{Result, Error}; -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use toolresults1_beta3::ToolResults; -/// -/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and -/// // `client_secret`, among other things. -/// let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = ToolResults::new(hyper::Client::new(), 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 = Step::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.projects().histories_executions_steps_patch(req, "projectId", "historyId", "executionId", "stepId") -/// .request_id("justo") -/// .doit(); -/// -/// 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::MissingAPIKey -/// |Error::MissingToken(_) -/// |Error::Cancelled -/// |Error::UploadSizeLimitExceeded(_, _) -/// |Error::Failure(_) -/// |Error::BadRequest(_) -/// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_, _) => println!("{}", e), -/// }, -/// Ok(res) => println!("Success: {:?}", res), -/// } -/// # } -/// ``` -pub struct ToolResults { - client: RefCell, - auth: RefCell, - _user_agent: String, -} - -impl<'a, C, A> Hub for ToolResults {} - -impl<'a, C, A> ToolResults - where C: BorrowMut, A: oauth2::GetToken { - - pub fn new(client: C, authenticator: A) -> ToolResults { - ToolResults { - client: RefCell::new(client), - auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.14".to_string(), - } - } - - pub fn projects(&'a self) -> ProjectMethods<'a, C, A> { - ProjectMethods { hub: &self } - } - - /// Set the user-agent header field to use in all requests to the server. - /// It defaults to `google-api-rust-client/0.1.14`. - /// - /// Returns the previously set user-agent. - pub fn user_agent(&mut self, agent_name: String) -> String { - let prev = self._user_agent.clone(); - self._user_agent = agent_name; - prev - } -} - - -// ############ -// SCHEMAS ### -// ########## -/// An image, with a link to the main image and a thumbnail. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Image { - /// An error explaining why the thumbnail could not be rendered. - pub error: Option, - /// The step to which the image is attached. - /// - /// Always set. - #[serde(rename="stepId")] - pub step_id: Option, - /// A reference to the full-size, original image. - /// - /// This is the same as the tool_outputs entry for the image under its Step. - /// - /// Always set. - #[serde(rename="sourceImage")] - pub source_image: Option, - /// The thumbnail. - pub thumbnail: Option, -} - -impl Part for Image {} - - -/// A stacktrace. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct StackTrace { - /// The stack trace message. - /// - /// Required - pub exception: Option, -} - -impl Part for StackTrace {} - - -/// A reference to a ToolExecution output file. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ToolOutputReference { - /// The test case to which this output file belongs. - /// - /// - In response: present if set by create/update request - In create/update request: optional - #[serde(rename="testCase")] - pub test_case: Option, - /// A FileReference to an output file. - /// - /// - In response: always set - In create/update request: always set - pub output: Option, - /// The creation time of the file. - /// - /// - In response: present if set by create/update request - In create/update request: optional - #[serde(rename="creationTime")] - pub creation_time: Option, -} - -impl Part for ToolOutputReference {} - - -/// A step that represents running tests. -/// -/// It accepts ant-junit xml files which will be parsed into structured test results by the service. Xml file paths are updated in order to append more files, however they can't be deleted. -/// -/// Users can also add test results manually by using the test_result field. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TestExecutionStep { - /// The timing break down of the test execution. - /// - /// - In response: present if set by create or update - In create/update request: optional - #[serde(rename="testTiming")] - pub test_timing: Option, - /// List of test suite overview contents. This could be parsed from xUnit XML log by server, or uploaded directly by user. This references should only be called when test suites are fully parsed or uploaded. - /// - /// The maximum allowed number of test suite overviews per step is 1000. - /// - /// - In response: always set - In create request: optional - In update request: never (use publishXunitXmlFiles custom method instead) - #[serde(rename="testSuiteOverviews")] - pub test_suite_overviews: Option>, - /// Represents the execution of the test runner. - /// - /// The exit code of this tool will be used to determine if the test passed. - /// - /// - In response: always set - In create/update request: optional - #[serde(rename="toolExecution")] - pub tool_execution: Option, - /// Issues observed during the test execution. - /// - /// For example, if the mobile app under test crashed during the test, the error message and the stack trace content can be recorded here to assist debugging. - /// - /// - In response: present if set by create or update - In create/update request: optional - #[serde(rename="testIssues")] - pub test_issues: Option>, -} - -impl Part for TestExecutionStep {} - - -/// Generic tool step to be used for binaries we do not explicitly support. For example: running cp to copy artifacts from one location to another. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ToolExecutionStep { - /// A Tool execution. - /// - /// - In response: present if set by create/update request - In create/update request: optional - #[serde(rename="toolExecution")] - pub tool_execution: Option, -} - -impl Part for ToolExecutionStep {} - - -/// An abnormal event observed during the test execution. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TestIssue { - /// Optional. - #[serde(rename="stackTrace")] - pub stack_trace: Option, - /// A brief human-readable message describing the abnormal event. - /// - /// Required. - #[serde(rename="errorMessage")] - pub error_message: Option, -} - -impl Part for TestIssue {} - - -/// A single thumbnail, with its size and format. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Thumbnail { - /// The thumbnail's content type, i.e. "image/png". - /// - /// Always set. - #[serde(rename="contentType")] - pub content_type: Option, - /// The width of the thumbnail, in pixels. - /// - /// Always set. - #[serde(rename="widthPx")] - pub width_px: Option, - /// The thumbnail file itself. - /// - /// That is, the bytes here are precisely the bytes that make up the thumbnail file; they can be served as an image as-is (with the appropriate content type.) - /// - /// Always set. - pub data: Option, - /// The height of the thumbnail, in pixels. - /// - /// Always set. - #[serde(rename="heightPx")] - pub height_px: Option, -} - -impl Part for Thumbnail {} - - -/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). The error model is designed to be: -/// -/// - Simple to use and understand for most users - Flexible enough to meet unexpected needs -/// -/// # Overview -/// -/// The `Status` message contains three pieces of data: error code, error message, and error details. The error code should be an enum value of [google.rpc.Code][], but it may accept additional error codes if needed. The error message should be a developer-facing English message that helps developers *understand* and *resolve* the error. If a localized user-facing error message is needed, put the localized message in the error details or localize it in the client. The optional error details may contain arbitrary information about the error. There is a predefined set of error detail types in the package `google.rpc` which can be used for common error conditions. -/// -/// # Language mapping -/// -/// The `Status` message is the logical representation of the error model, but it is not necessarily the actual wire format. When the `Status` message is exposed in different client libraries and different wire protocols, it can be mapped differently. For example, it will likely be mapped to some exceptions in Java, but more likely mapped to some error codes in C. -/// -/// # Other uses -/// -/// The error model and the `Status` message can be used in a variety of environments, either with or without APIs, to provide a consistent developer experience across different environments. -/// -/// Example uses of this error model include: -/// -/// - Partial errors. If a service needs to return partial errors to the client, it may embed the `Status` in the normal response to indicate the partial errors. -/// -/// - Workflow errors. A typical workflow has multiple steps. Each step may have a `Status` message for error reporting purpose. -/// -/// - Batch operations. If a client uses batch request and batch response, the `Status` message should be used directly inside batch response, one for each error sub-response. -/// -/// - Asynchronous operations. If an API call embeds asynchronous operation results in its response, the status of those operations should be represented directly using the `Status` message. -/// -/// - Logging. If some API errors are stored in logs, the message `Status` could be used directly after any stripping needed for security/privacy reasons. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Status { - /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][] field, or localized by the client. - pub message: Option, - /// The status code, which should be an enum value of [google.rpc.Code][]. - pub code: Option, - /// A list of messages that carry the error details. There will be a common set of message types for APIs to use. - pub details: Option>, -} - -impl Part for Status {} - - -/// Response message for StepService.List. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [histories executions steps list projects](struct.ProjectHistoryExecutionStepListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListStepsResponse { - /// A continuation token to resume the query at the next item. - /// - /// If set, indicates that there are more steps to read, by calling list again with this value in the page_token field. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// Steps. - pub steps: Option>, -} - -impl ResponseResult for ListStepsResponse {} - - -/// A Step represents a single operation performed as part of Execution. A step can be used to represent the execution of a tool ( for example a test runner execution or an execution of a compiler). -/// -/// Steps can overlap (for instance two steps might have the same start time if some operations are done in parallel). -/// -/// Here is an example, let's consider that we have a continuous build is executing a test runner for each iteration. The workflow would look like: - user creates a Execution with id 1 - user creates an TestExecutionStep with id 100 for Execution 1 - user update TestExecutionStep with id 100 to add a raw xml log + the service parses the xml logs and returns a TestExecutionStep with updated TestResult(s). - user update the status of TestExecutionStep with id 100 to COMPLETE -/// -/// A Step can be updated until its state is set to COMPLETE at which points it becomes immutable. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [histories executions steps patch projects](struct.ProjectHistoryExecutionStepPatchCall.html) (request|response) -/// * [histories executions steps get projects](struct.ProjectHistoryExecutionStepGetCall.html) (response) -/// * [histories executions steps publish xunit xml files projects](struct.ProjectHistoryExecutionStepPublishXunitXmlFileCall.html) (response) -/// * [histories executions steps create projects](struct.ProjectHistoryExecutionStepCreateCall.html) (request|response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Step { - /// An execution of a test runner. - #[serde(rename="testExecutionStep")] - pub test_execution_step: Option, - /// A unique identifier within a Execution for this Step. - /// - /// Returns INVALID_ARGUMENT if this field is set or overwritten by the caller. - /// - /// - In response: always set - In create/update request: never set - #[serde(rename="stepId")] - pub step_id: Option, - /// How long it took for this step to run. - /// - /// If unset, this is set to the difference between creation_time and completion_time when the step is set to the COMPLETE state. In some cases, it is appropriate to set this value separately: For instance, if a step is created, but the operation it represents is queued for a few minutes before it executes, it would be appropriate not to include the time spent queued in its run_duration. - /// - /// PRECONDITION_FAILED will be returned if one attempts to set a run_duration on a step which already has this field set. - /// - /// - In response: present if previously set; always present on COMPLETE step - In create request: optional - In update request: optional - #[serde(rename="runDuration")] - pub run_duration: Option, - /// A description of this tool For example: mvn clean package -D skipTests=true - /// - /// - In response: present if set by create/update request - In create/update request: optional - pub description: Option, - /// Arbitrary user-supplied key/value pairs that are associated with the step. - /// - /// Users are responsible for managing the key namespace such that keys don't accidentally collide. - /// - /// An INVALID_ARGUMENT will be returned if the number of labels exceeds 100 or if the length of any of the keys or values exceeds 100 characters. - /// - /// - In response: always set - In create request: optional - In update request: optional; any new key/value pair will be added to the map, and any new value for an existing key will update that key's value - pub labels: Option>, - /// The time when the step was created. - /// - /// - In response: always set - In create/update request: never set - #[serde(rename="creationTime")] - pub creation_time: Option, - /// An execution of a tool (used for steps we don't explicitly support). - #[serde(rename="toolExecutionStep")] - pub tool_execution_step: Option, - /// The initial state is IN_PROGRESS. The only legal state transitions are * IN_PROGRESS -> COMPLETE - /// - /// A PRECONDITION_FAILED will be returned if an invalid transition is requested. - /// - /// It is valid to create Step with a state set to COMPLETE. The state can only be set to COMPLETE once. A PRECONDITION_FAILED will be returned if the state is set to COMPLETE multiple times. - /// - /// - In response: always set - In create/update request: optional - pub state: Option, - /// The time when the step status was set to complete. - /// - /// This value will be set automatically when state transitions to COMPLETE. - /// - /// - In response: set if the execution state is COMPLETE. - In create/update request: never set - #[serde(rename="completionTime")] - pub completion_time: Option, - /// Whether any of the outputs of this step are images whose thumbnails can be fetched with ListThumbnails. - /// - /// - In response: always set - In create/update request: never set - #[serde(rename="hasImages")] - pub has_images: Option, - /// If the execution containing this step has any dimension_definition set, then this field allows the child to specify the values of the dimensions. - /// - /// The keys must exactly match the dimension_definition of the execution. - /// - /// For example, if the execution has `dimension_definition = ['attempt', 'device']` then a step must define values for those dimensions, eg. `dimension_value = ['attempt': '1', 'device': 'Nexus 6']` - /// - /// If a step does not participate in one dimension of the matrix, the value for that dimension should be empty string. For example, if one of the tests is executed by a runner which does not support retries, the step could have `dimension_value = ['attempt': '', 'device': 'Nexus 6']` - /// - /// If the step does not participate in any dimensions of the matrix, it may leave dimension_value unset. - /// - /// A PRECONDITION_FAILED will be returned if any of the keys do not exist in the dimension_definition of the execution. - /// - /// A PRECONDITION_FAILED will be returned if another step in this execution already has the same name and dimension_value, but differs on other data fields, for example, step field is different. - /// - /// A PRECONDITION_FAILED will be returned if dimension_value is set, and there is a dimension_definition in the execution which is not specified as one of the keys. - /// - /// - In response: present if set by create - In create request: optional - In update request: never set - #[serde(rename="dimensionValue")] - pub dimension_value: Option>, - /// Classification of the result, for example into SUCCESS or FAILURE - /// - /// - In response: present if set by create/update request - In create/update request: optional - pub outcome: Option, - /// How much the device resource is used to perform the test. - /// - /// This is the device usage used for billing purpose, which is different from the run_duration, for example, infrastructure failure won't be charged for device usage. - /// - /// PRECONDITION_FAILED will be returned if one attempts to set a device_usage on a step which already has this field set. - /// - /// - In response: present if previously set. - In create request: optional - In update request: optional - #[serde(rename="deviceUsageDuration")] - pub device_usage_duration: Option, - /// A short human-readable name to display in the UI. Maximum of 100 characters. For example: Clean build - /// - /// A PRECONDITION_FAILED will be returned upon creating a new step if it shares its name and dimension_value with an existing step. If two steps represent a similar action, but have different dimension values, they should share the same name. For instance, if the same set of tests is run on two different platforms, the two steps should have the same name. - /// - /// - In response: always set - In create request: always set - In update request: never set - pub name: Option, -} - -impl RequestValue for Step {} -impl ResponseResult for Step {} - - -/// A reference to a test case. -/// -/// Test case references are canonically ordered lexicographically by these three factors: * First, by test_suite_name. * Second, by class_name. * Third, by name. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TestCaseReference { - /// The name of the class. - #[serde(rename="className")] - pub class_name: Option, - /// The name of the test suite to which this test case belongs. - #[serde(rename="testSuiteName")] - pub test_suite_name: Option, - /// The name of the test case. - /// - /// Required. - pub name: Option, -} - -impl Part for TestCaseReference {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct InconclusiveDetail { - /// If the test runner could not determine success or failure because the test depends on a component other than the system under test which failed. - /// - /// For example, a mobile test requires provisioning a device where the test executes, and that provisioning can fail. - #[serde(rename="infrastructureFailure")] - pub infrastructure_failure: Option, - /// A native process crashed on the device, producing a tombstone. It is unclear whether the crash was related to the app under test. - /// - /// For example, OpenGL crashed, but it is unclear if the app is responsible. - #[serde(rename="nativeCrash")] - pub native_crash: Option, - /// If the end user aborted the test execution before a pass or fail could be determined. For example, the user pressed ctrl-c which sent a kill signal to the test runner while the test was running. - #[serde(rename="abortedByUser")] - pub aborted_by_user: Option, -} - -impl Part for InconclusiveDetail {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct StepLabelsEntry { - /// no description provided - pub key: Option, - /// no description provided - pub value: Option, -} - -impl Part for StepLabelsEntry {} - - -/// An Execution represents a collection of Steps. For instance, it could represent: - a mobile test executed across a range of device configurations - a jenkins job with a build step followed by a test step -/// -/// The maximum size of an execution message is 1 MiB. -/// -/// An Execution can be updated until its state is set to COMPLETE at which point it becomes immutable. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [histories executions patch projects](struct.ProjectHistoryExecutionPatchCall.html) (request|response) -/// * [histories executions create projects](struct.ProjectHistoryExecutionCreateCall.html) (request|response) -/// * [histories executions get projects](struct.ProjectHistoryExecutionGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Execution { - /// The initial state is IN_PROGRESS. - /// - /// The only legal state transitions is from IN_PROGRESS to COMPLETE. - /// - /// A PRECONDITION_FAILED will be returned if an invalid transition is requested. - /// - /// The state can only be set to COMPLETE once. A FAILED_PRECONDITION will be returned if the state is set to COMPLETE multiple times. - /// - /// If the state is set to COMPLETE, all the in-progress steps within the execution will be set as COMPLETE. If the outcome of the step is not set, the outcome will be set to INCONCLUSIVE. - /// - /// - In response always set - In create/update request: optional - pub state: Option, - /// TestExecution Matrix ID that the Test Service uses. - /// - /// - In response: present if set by create - In create: optional - In update: never set - #[serde(rename="testExecutionMatrixId")] - pub test_execution_matrix_id: Option, - /// The time when the Execution status transitioned to COMPLETE. - /// - /// This value will be set automatically when state transitions to COMPLETE. - /// - /// - In response: set if the execution state is COMPLETE. - In create/update request: never set - #[serde(rename="completionTime")] - pub completion_time: Option, - /// Classify the result, for example into SUCCESS or FAILURE - /// - /// - In response: present if set by create/update request - In create/update request: optional - pub outcome: Option, - /// The time when the Execution was created. - /// - /// This value will be set automatically when CreateExecution is called. - /// - /// - In response: always set - In create/update request: never set - #[serde(rename="creationTime")] - pub creation_time: Option, - /// A unique identifier within a History for this Execution. - /// - /// Returns INVALID_ARGUMENT if this field is set or overwritten by the caller. - /// - /// - In response always set - In create/update request: never set - #[serde(rename="executionId")] - pub execution_id: Option, -} - -impl RequestValue for Execution {} -impl ResponseResult for Execution {} - - -/// Testing timing break down to know phases. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TestTiming { - /// How long it took to run the test process. - /// - /// - In response: present if previously set. - In create/update request: optional - #[serde(rename="testProcessDuration")] - pub test_process_duration: Option, -} - -impl Part for TestTiming {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SuccessDetail { - /// If a native process other than the app crashed. - #[serde(rename="otherNativeCrash")] - pub other_native_crash: Option, -} - -impl Part for SuccessDetail {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct StepDimensionValueEntry { - /// no description provided - pub key: Option, - /// no description provided - pub value: Option, -} - -impl Part for StepDimensionValueEntry {} - - -/// Per-project settings for the Tool Results service. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [initialize settings projects](struct.ProjectInitializeSettingCall.html) (response) -/// * [get settings projects](struct.ProjectGetSettingCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ProjectSettings { - /// The name of the Google Cloud Storage bucket to which results are written. - /// - /// By default, this is unset. - /// - /// In update request: optional In response: optional - #[serde(rename="defaultBucket")] - pub default_bucket: Option, - /// The name of the project's settings. - /// - /// Always of the form: projects/{project-id}/settings - /// - /// In update request: never set In response: always set - pub name: Option, -} - -impl ResponseResult for ProjectSettings {} - - -/// A reference to a file. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct FileReference { - /// The URI of a file stored in Google Cloud Storage. - /// - /// For example: http://storage.googleapis.com/mybucket/path/to/test.xml or in gsutil format: gs://mybucket/path/to/test.xml with version-specific info, gs://mybucket/path/to/test.xml#1360383693690000 - /// - /// An INVALID_ARGUMENT error will be returned if the URI format is not supported. - /// - /// - In response: always set - In create/update request: always set - #[serde(rename="fileUri")] - pub file_uri: Option, -} - -impl Part for FileReference {} - - -/// A response containing the thumbnails in a step. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [histories executions steps thumbnails list projects](struct.ProjectHistoryExecutionStepThumbnailListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListStepThumbnailsResponse { - /// A continuation token to resume the query at the next item. - /// - /// If set, indicates that there are more thumbnails to read, by calling list again with this value in the page_token field. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// A list of image data. - /// - /// Images are returned in a deterministic order; they are ordered by these factors, in order of importance: * First, by their associated test case. Images without a test case are considered greater than images with one. * Second, by their creation time. Images without a creation time are greater than images with one. * Third, by the order in which they were added to the step (by calls to CreateStep or UpdateStep). - pub thumbnails: Option>, -} - -impl ResponseResult for ListStepThumbnailsResponse {} - - -/// Interprets a result so that humans and machines can act on it. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Outcome { - /// More information about an INCONCLUSIVE outcome. - /// - /// Returns INVALID_ARGUMENT if this field is set but the summary is not INCONCLUSIVE. - /// - /// Optional - #[serde(rename="inconclusiveDetail")] - pub inconclusive_detail: Option, - /// More information about a SKIPPED outcome. - /// - /// Returns INVALID_ARGUMENT if this field is set but the summary is not SKIPPED. - /// - /// Optional - #[serde(rename="skippedDetail")] - pub skipped_detail: Option, - /// More information about a SUCCESS outcome. - /// - /// Returns INVALID_ARGUMENT if this field is set but the summary is not SUCCESS. - /// - /// Optional - #[serde(rename="successDetail")] - pub success_detail: Option, - /// More information about a FAILURE outcome. - /// - /// Returns INVALID_ARGUMENT if this field is set but the summary is not FAILURE. - /// - /// Optional - #[serde(rename="failureDetail")] - pub failure_detail: Option, - /// The simplest way to interpret a result. - /// - /// Required - pub summary: Option, -} - -impl Part for Outcome {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct FailureDetail { - /// If a native process other than the app crashed. - #[serde(rename="otherNativeCrash")] - pub other_native_crash: Option, - /// If the failure was severe because the system under test crashed. - pub crashed: Option, - /// If an app is not installed and thus no test can be run with the app. This might be caused by trying to run a test on an unsupported platform. - #[serde(rename="notInstalled")] - pub not_installed: Option, - /// If the test overran some time limit, and that is why it failed. - #[serde(rename="timedOut")] - pub timed_out: Option, -} - -impl Part for FailureDetail {} - - -/// A History represents a sorted list of Executions ordered by the start_timestamp_millis field (descending). It can be used to group all the Executions of a continuous build. -/// -/// Note that the ordering only operates on one-dimension. If a repository has multiple branches, it means that multiple histories will need to be used in order to order Executions per branch. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [histories get projects](struct.ProjectHistoryGetCall.html) (response) -/// * [histories create projects](struct.ProjectHistoryCreateCall.html) (request|response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct History { - /// A short human-readable (plain text) name to display in the UI. Maximum of 100 characters. - /// - /// - In response: present if set during create. - In create request: optional - #[serde(rename="displayName")] - pub display_name: Option, - /// A name to uniquely identify a history within a project. Maximum of 100 characters. - /// - /// - In response always set - In create request: always set - pub name: Option, - /// A unique identifier within a project for this History. - /// - /// Returns INVALID_ARGUMENT if this field is set or overwritten by the caller. - /// - /// - In response always set - In create request: never set - #[serde(rename="historyId")] - pub history_id: Option, -} - -impl RequestValue for History {} -impl ResponseResult for History {} - - -/// Request message for StepService.PublishXunitXmlFiles. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [histories executions steps publish xunit xml files projects](struct.ProjectHistoryExecutionStepPublishXunitXmlFileCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PublishXunitXmlFilesRequest { - /// URI of the Xunit XML files to publish. - /// - /// The maximum size of the file this reference is pointing to is 50MB. - /// - /// Required. - #[serde(rename="xunitXmlFiles")] - pub xunit_xml_files: Option>, -} - -impl RequestValue for PublishXunitXmlFilesRequest {} - - -/// Response message for HistoryService.List -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [histories list projects](struct.ProjectHistoryListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListHistoriesResponse { - /// A continuation token to resume the query at the next item. - /// - /// Will only be set if there are more histories to fetch. - /// - /// Tokens are valid for up to one hour from the time of the first list request. For instance, if you make a list request at 1PM and use the token from this first request 10 minutes later, the token from this second response will only be valid for 50 minutes. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// Histories. - pub histories: Option>, -} - -impl ResponseResult for ListHistoriesResponse {} - - -/// An execution of an arbitrary tool. It could be a test runner or a tool copying artifacts or deploying code. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ToolExecution { - /// The full tokenized command line including the program name (equivalent to argv in a C program). - /// - /// - In response: present if set by create request - In create request: optional - In update request: never set - #[serde(rename="commandLineArguments")] - pub command_line_arguments: Option>, - /// References to any plain text logs output the tool execution. - /// - /// This field can be set before the tool has exited in order to be able to have access to a live view of the logs while the tool is running. - /// - /// The maximum allowed number of tool logs per step is 1000. - /// - /// - In response: present if set by create/update request - In create request: optional - In update request: optional, any value provided will be appended to the existing list - #[serde(rename="toolLogs")] - pub tool_logs: Option>, - /// References to opaque files of any format output by the tool execution. - /// - /// The maximum allowed number of tool outputs per step is 1000. - /// - /// - In response: present if set by create/update request - In create request: optional - In update request: optional, any value provided will be appended to the existing list - #[serde(rename="toolOutputs")] - pub tool_outputs: Option>, - /// Tool execution exit code. This field will be set once the tool has exited. - /// - /// - In response: present if set by create/update request - In create request: optional - In update request: optional, a FAILED_PRECONDITION error will be returned if an exit_code is already set. - #[serde(rename="exitCode")] - pub exit_code: Option, -} - -impl Part for ToolExecution {} - - -/// Exit code from a tool execution. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ToolExitCode { - /// Tool execution exit code. A value of 0 means that the execution was successful. - /// - /// - In response: always set - In create/update request: always set - pub number: Option, -} - -impl Part for ToolExitCode {} - - -/// There is no detailed description. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [histories executions list projects](struct.ProjectHistoryExecutionListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListExecutionsResponse { - /// A continuation token to resume the query at the next item. - /// - /// Will only be set if there are more Executions to fetch. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// Executions. - /// - /// Always set. - pub executions: Option>, -} - -impl ResponseResult for ListExecutionsResponse {} - - -/// There is no detailed description. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SkippedDetail { - /// If the App doesn't support the specific API level. - #[serde(rename="incompatibleAppVersion")] - pub incompatible_app_version: Option, - /// If the App doesn't run on the specific architecture, for example, x86. - #[serde(rename="incompatibleArchitecture")] - pub incompatible_architecture: Option, - /// If the requested OS version doesn't run on the specific device model. - #[serde(rename="incompatibleDevice")] - pub incompatible_device: Option, -} - -impl Part for SkippedDetail {} - - -/// A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time. It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By restricting to that range, we ensure that we can convert to and from RFC 3339 date strings. See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). -/// -/// Example 1: Compute Timestamp from POSIX `time()`. -/// -/// Timestamp timestamp; timestamp.set_seconds(time(NULL)); timestamp.set_nanos(0); -/// -/// Example 2: Compute Timestamp from POSIX `gettimeofday()`. -/// -/// struct timeval tv; gettimeofday(&tv, NULL); -/// -/// Timestamp timestamp; timestamp.set_seconds(tv.tv_sec); timestamp.set_nanos(tv.tv_usec * 1000); -/// -/// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. -/// -/// FILETIME ft; GetSystemTimeAsFileTime(&ft); UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; -/// -/// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. Timestamp timestamp; timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); -/// -/// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. -/// -/// long millis = System.currentTimeMillis(); -/// -/// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) .setNanos((int) ((millis % 1000) * 1000000)).build(); -/// -/// -/// -/// Example 5: Compute Timestamp from current time in Python. -/// -/// now = time.time() seconds = int(now) nanos = int((now - seconds) * 10**9) timestamp = Timestamp(seconds=seconds, nanos=nanos) -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Timestamp { - /// Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be from 0 to 999,999,999 inclusive. - pub nanos: Option, - /// Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive. - pub seconds: Option, -} - -impl Part for Timestamp {} - - -/// A Duration represents a signed, fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond resolution. It is independent of any calendar and concepts like "day" or "month". It is related to Timestamp in that the difference between two Timestamp values is a Duration and it can be added or subtracted from a Timestamp. Range is approximately +-10,000 years. -/// -/// Example 1: Compute Duration from two Timestamps in pseudo code. -/// -/// Timestamp start = ...; Timestamp end = ...; Duration duration = ...; -/// -/// duration.seconds = end.seconds - start.seconds; duration.nanos = end.nanos - start.nanos; -/// -/// if (duration.seconds 0) { duration.seconds += 1; duration.nanos -= 1000000000; } else if (durations.seconds > 0 && duration.nanos < 0) { duration.seconds -= 1; duration.nanos += 1000000000; } -/// -/// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. -/// -/// Timestamp start = ...; Duration duration = ...; Timestamp end = ...; -/// -/// end.seconds = start.seconds + duration.seconds; end.nanos = start.nanos + duration.nanos; -/// -/// if (end.nanos = 1000000000) { end.seconds += 1; end.nanos -= 1000000000; } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Duration { - /// Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 `seconds` field and a positive or negative `nanos` field. For durations of one second or more, a non-zero value for the `nanos` field must be of the same sign as the `seconds` field. Must be from -999,999,999 to +999,999,999 inclusive. - pub nanos: Option, - /// Signed seconds of the span of time. Must be from -315,576,000,000 to +315,576,000,000 inclusive. - pub seconds: Option, -} - -impl Part for Duration {} - - -/// A summary of a test suite result either parsed from XML or uploaded directly by a user. -/// -/// Note: the API related comments are for StepService only. This message is also being used in ExecutionService in a read only mode for the corresponding step. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TestSuiteOverview { - /// If this test suite was parsed from XML, this is the URI where the original XML file is stored. - /// - /// Note: Multiple test suites can share the same xml_source - /// - /// Returns INVALID_ARGUMENT if the uri format is not supported. - /// - /// - In create/response: optional - In update request: never - #[serde(rename="xmlSource")] - pub xml_source: Option, - /// Number of test cases, typically set by the service by parsing the xml_source. - /// - /// - In create/response: always set - In update request: never - #[serde(rename="totalCount")] - pub total_count: Option, - /// The name of the test suite. - /// - /// - In create/response: always set - In update request: never - pub name: Option, - /// Number of test cases in error, typically set by the service by parsing the xml_source. - /// - /// - In create/response: always set - In update request: never - #[serde(rename="errorCount")] - pub error_count: Option, - /// Number of test cases not run, typically set by the service by parsing the xml_source. - /// - /// - In create/response: always set - In update request: never - #[serde(rename="skippedCount")] - pub skipped_count: Option, - /// Number of failed test cases, typically set by the service by parsing the xml_source. May also be set by the user. - /// - /// - In create/response: always set - In update request: never - #[serde(rename="failureCount")] - pub failure_count: Option, -} - -impl Part for TestSuiteOverview {} - - -/// `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. -/// -/// Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type. -/// -/// Example 1: Pack and unpack a message in C++. -/// -/// Foo foo = ...; Any any; any.PackFrom(foo); ... if (any.UnpackTo(&foo)) { ... } -/// -/// Example 2: Pack and unpack a message in Java. -/// -/// Foo foo = ...; Any any = Any.pack(foo); ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } -/// -/// The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example "foo.bar.com/x/y.z" will yield type name "y.z". -/// -/// -/// -/// JSON ==== The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: -/// -/// package google.profile; message Person { string first_name = 1; string last_name = 2; } -/// -/// { "@type": "type.googleapis.com/google.profile.Person", "firstName": , "lastName": } -/// -/// If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the `@type` field. Example (for message [google.protobuf.Duration][]): -/// -/// { "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Any { - /// A URL/resource name whose content describes the type of the serialized protocol buffer message. - /// - /// For URLs which use the schema `http`, `https`, or no schema, the following restrictions and interpretations apply: - /// - /// * If no schema is provided, `https` is assumed. * The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). * An HTTP GET on the URL must yield a [google.protobuf.Type][] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) - /// - /// Schemas other than `http`, `https` (or the empty schema) might be used with implementation specific semantics. - #[serde(rename="typeUrl")] - pub type_url: Option, - /// Must be a valid serialized protocol buffer of the above specified type. - pub value: Option, -} - -impl Part for Any {} - - - -// ################### -// MethodBuilders ### -// ################# - -/// A builder providing access to all methods supported on *project* resources. -/// It is not used directly, but through the `ToolResults` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use toolresults1_beta3::ToolResults; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = ToolResults::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get_settings(...)`, `histories_create(...)`, `histories_executions_create(...)`, `histories_executions_get(...)`, `histories_executions_list(...)`, `histories_executions_patch(...)`, `histories_executions_steps_create(...)`, `histories_executions_steps_get(...)`, `histories_executions_steps_list(...)`, `histories_executions_steps_patch(...)`, `histories_executions_steps_publish_xunit_xml_files(...)`, `histories_executions_steps_thumbnails_list(...)`, `histories_get(...)`, `histories_list(...)` and `initialize_settings(...)` -/// // to build up your call. -/// let rb = hub.projects(); -/// # } -/// ``` -pub struct ProjectMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, -} - -impl<'a, C, A> MethodsBuilder for ProjectMethods<'a, C, A> {} - -impl<'a, C, A> ProjectMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Creates resources for settings which have not yet been set. - /// - /// Currently, this creates a single resource: a Google Cloud Storage bucket, to be used as the default bucket for this project. The bucket is created in the name of the user calling. Except in rare cases, calling this method in parallel from multiple clients will only create a single bucket. In order to avoid unnecessary storage charges, the bucket is configured to automatically delete objects older than 90 days. - /// - /// The bucket is created with the project-private ACL: All project team members are given permissions to the bucket and objects created within it according to their roles. Project owners have owners rights, and so on. The default ACL on objects created in the bucket is project-private as well. See Google Cloud Storage documentation for more details. - /// - /// If there is already a default bucket set and the project can access the bucket, this call does nothing. However, if the project doesn't have the permission to access the bucket or the bucket is deteleted, a new bucket will be created. - /// - /// May return any canonical error codes, including the following: - /// - /// - PERMISSION_DENIED - if the user is not authorized to write to project - Any error code raised by Google Cloud Storage - /// - /// # Arguments - /// - /// * `projectId` - A Project id. - /// Required. - pub fn initialize_settings(&self, project_id: &str) -> ProjectInitializeSettingCall<'a, C, A> { - ProjectInitializeSettingCall { - hub: self.hub, - _project_id: project_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Gets a History. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the History does not exist - /// - /// # Arguments - /// - /// * `projectId` - A Project id. - /// Required. - /// * `historyId` - A History id. - /// Required. - pub fn histories_get(&self, project_id: &str, history_id: &str) -> ProjectHistoryGetCall<'a, C, A> { - ProjectHistoryGetCall { - hub: self.hub, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists thumbnails of images attached to a step. - /// - /// May return any of the following canonical error codes: - PERMISSION_DENIED - if the user is not authorized to read from the project, or from any of the images - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the step does not exist, or if any of the images do not exist - /// - /// # Arguments - /// - /// * `projectId` - A Project id. - /// Required. - /// * `historyId` - A History id. - /// Required. - /// * `executionId` - An Execution id. - /// Required. - /// * `stepId` - A Step id. - /// Required. - pub fn histories_executions_steps_thumbnails_list(&self, project_id: &str, history_id: &str, execution_id: &str, step_id: &str) -> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> { - ProjectHistoryExecutionStepThumbnailListCall { - hub: self.hub, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _execution_id: execution_id.to_string(), - _step_id: step_id.to_string(), - _page_token: Default::default(), - _page_size: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Gets an Execution. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the Execution does not exist - /// - /// # Arguments - /// - /// * `projectId` - A Project id. - /// Required. - /// * `historyId` - A History id. - /// Required. - /// * `executionId` - An Execution id. - /// Required. - pub fn histories_executions_get(&self, project_id: &str, history_id: &str, execution_id: &str) -> ProjectHistoryExecutionGetCall<'a, C, A> { - ProjectHistoryExecutionGetCall { - hub: self.hub, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _execution_id: execution_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates an existing Execution with the supplied partial entity. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the requested state transition is illegal - NOT_FOUND - if the containing History does not exist - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `projectId` - A Project id. Required. - /// * `historyId` - Required. - /// * `executionId` - Required. - pub fn histories_executions_patch(&self, request: Execution, project_id: &str, history_id: &str, execution_id: &str) -> ProjectHistoryExecutionPatchCall<'a, C, A> { - ProjectHistoryExecutionPatchCall { - hub: self.hub, - _request: request, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _execution_id: execution_id.to_string(), - _request_id: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists Histories for a given Project. - /// - /// The histories are sorted by modification time in descending order. The history_id key will be used to order the history with the same modification time. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the History does not exist - /// - /// # Arguments - /// - /// * `projectId` - A Project id. - /// Required. - pub fn histories_list(&self, project_id: &str) -> ProjectHistoryListCall<'a, C, A> { - ProjectHistoryListCall { - hub: self.hub, - _project_id: project_id.to_string(), - _page_token: Default::default(), - _page_size: Default::default(), - _filter_by_name: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Gets a Step. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the Step does not exist - /// - /// # Arguments - /// - /// * `projectId` - A Project id. - /// Required. - /// * `historyId` - A History id. - /// Required. - /// * `executionId` - A Execution id. - /// Required. - /// * `stepId` - A Step id. - /// Required. - pub fn histories_executions_steps_get(&self, project_id: &str, history_id: &str, execution_id: &str, step_id: &str) -> ProjectHistoryExecutionStepGetCall<'a, C, A> { - ProjectHistoryExecutionStepGetCall { - hub: self.hub, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _execution_id: execution_id.to_string(), - _step_id: step_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Publish xml files to an existing Step. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to write project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the requested state transition is illegal, e.g try to upload a duplicate xml file or a file too large. - NOT_FOUND - if the containing Execution does not exist - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `projectId` - A Project id. - /// Required. - /// * `historyId` - A History id. - /// Required. - /// * `executionId` - A Execution id. - /// Required. - /// * `stepId` - A Step id. Note: This step must include a TestExecutionStep. - /// Required. - pub fn histories_executions_steps_publish_xunit_xml_files(&self, request: PublishXunitXmlFilesRequest, project_id: &str, history_id: &str, execution_id: &str, step_id: &str) -> ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> { - ProjectHistoryExecutionStepPublishXunitXmlFileCall { - hub: self.hub, - _request: request, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _execution_id: execution_id.to_string(), - _step_id: step_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists Steps for a given Execution. - /// - /// The steps are sorted by creation_time in descending order. The step_id key will be used to order the steps with the same creation_time. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if an argument in the request happens to be invalid; e.g. if an attempt is made to list the children of a nonexistent Step - NOT_FOUND - if the containing Execution does not exist - /// - /// # Arguments - /// - /// * `projectId` - A Project id. - /// Required. - /// * `historyId` - A History id. - /// Required. - /// * `executionId` - A Execution id. - /// Required. - pub fn histories_executions_steps_list(&self, project_id: &str, history_id: &str, execution_id: &str) -> ProjectHistoryExecutionStepListCall<'a, C, A> { - ProjectHistoryExecutionStepListCall { - hub: self.hub, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _execution_id: execution_id.to_string(), - _page_token: Default::default(), - _page_size: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates an existing Step with the supplied partial entity. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to write project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the requested state transition is illegal (e.g try to upload a duplicate xml file), if the updated step is too large (more than 10Mib) - NOT_FOUND - if the containing Execution does not exist - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `projectId` - A Project id. - /// Required. - /// * `historyId` - A History id. - /// Required. - /// * `executionId` - A Execution id. - /// Required. - /// * `stepId` - A Step id. - /// Required. - pub fn histories_executions_steps_patch(&self, request: Step, project_id: &str, history_id: &str, execution_id: &str, step_id: &str) -> ProjectHistoryExecutionStepPatchCall<'a, C, A> { - ProjectHistoryExecutionStepPatchCall { - hub: self.hub, - _request: request, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _execution_id: execution_id.to_string(), - _step_id: step_id.to_string(), - _request_id: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates an Execution. - /// - /// The returned Execution will have the id set. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the containing History does not exist - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `projectId` - A Project id. - /// Required. - /// * `historyId` - A History id. - /// Required. - pub fn histories_executions_create(&self, request: Execution, project_id: &str, history_id: &str) -> ProjectHistoryExecutionCreateCall<'a, C, A> { - ProjectHistoryExecutionCreateCall { - hub: self.hub, - _request: request, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _request_id: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a Step. - /// - /// The returned Step will have the id set. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the step is too large (more than 10Mib) - NOT_FOUND - if the containing Execution does not exist - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `projectId` - A Project id. - /// Required. - /// * `historyId` - A History id. - /// Required. - /// * `executionId` - A Execution id. - /// Required. - pub fn histories_executions_steps_create(&self, request: Step, project_id: &str, history_id: &str, execution_id: &str) -> ProjectHistoryExecutionStepCreateCall<'a, C, A> { - ProjectHistoryExecutionStepCreateCall { - hub: self.hub, - _request: request, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _execution_id: execution_id.to_string(), - _request_id: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Gets the Tool Results settings for a project. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to read from project - /// - /// # Arguments - /// - /// * `projectId` - A Project id. - /// Required. - pub fn get_settings(&self, project_id: &str) -> ProjectGetSettingCall<'a, C, A> { - ProjectGetSettingCall { - hub: self.hub, - _project_id: project_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists Histories for a given Project. - /// - /// The executions are sorted by creation_time in descending order. The execution_id key will be used to order the executions with the same creation_time. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the containing History does not exist - /// - /// # Arguments - /// - /// * `projectId` - A Project id. - /// Required. - /// * `historyId` - A History id. - /// Required. - pub fn histories_executions_list(&self, project_id: &str, history_id: &str) -> ProjectHistoryExecutionListCall<'a, C, A> { - ProjectHistoryExecutionListCall { - hub: self.hub, - _project_id: project_id.to_string(), - _history_id: history_id.to_string(), - _page_token: Default::default(), - _page_size: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a History. - /// - /// The returned History will have the id set. - /// - /// May return any of the following canonical error codes: - /// - /// - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the containing project does not exist - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `projectId` - A Project id. - /// Required. - pub fn histories_create(&self, request: History, project_id: &str) -> ProjectHistoryCreateCall<'a, C, A> { - ProjectHistoryCreateCall { - hub: self.hub, - _request: request, - _project_id: project_id.to_string(), - _request_id: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - - - -// ################### -// CallBuilders ### -// ################# - -/// Creates resources for settings which have not yet been set. -/// -/// Currently, this creates a single resource: a Google Cloud Storage bucket, to be used as the default bucket for this project. The bucket is created in the name of the user calling. Except in rare cases, calling this method in parallel from multiple clients will only create a single bucket. In order to avoid unnecessary storage charges, the bucket is configured to automatically delete objects older than 90 days. -/// -/// The bucket is created with the project-private ACL: All project team members are given permissions to the bucket and objects created within it according to their roles. Project owners have owners rights, and so on. The default ACL on objects created in the bucket is project-private as well. See Google Cloud Storage documentation for more details. -/// -/// If there is already a default bucket set and the project can access the bucket, this call does nothing. However, if the project doesn't have the permission to access the bucket or the bucket is deteleted, a new bucket will be created. -/// -/// May return any canonical error codes, including the following: -/// -/// - PERMISSION_DENIED - if the user is not authorized to write to project - Any error code raised by Google Cloud Storage -/// -/// A builder for the *initializeSettings* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), auth); -/// // 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.projects().initialize_settings("projectId") -/// .doit(); -/// # } -/// ``` -pub struct ProjectInitializeSettingCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _project_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectInitializeSettingCall<'a, C, A> {} - -impl<'a, C, A> ProjectInitializeSettingCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ProjectSettings)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.initializeSettings", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - for &field in ["alt", "projectId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}:initializeSettings".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectInitializeSettingCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectInitializeSettingCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectInitializeSettingCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectInitializeSettingCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Gets a History. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the History does not exist -/// -/// A builder for the *histories.get* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), auth); -/// // 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.projects().histories_get("projectId", "historyId") -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _project_id: String, - _history_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryGetCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, History)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - for &field in ["alt", "projectId", "historyId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryGetCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A History id. - /// - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryGetCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Lists thumbnails of images attached to a step. -/// -/// May return any of the following canonical error codes: - PERMISSION_DENIED - if the user is not authorized to read from the project, or from any of the images - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the step does not exist, or if any of the images do not exist -/// -/// A builder for the *histories.executions.steps.thumbnails.list* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), auth); -/// // 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.projects().histories_executions_steps_thumbnails_list("projectId", "historyId", "executionId", "stepId") -/// .page_token("sadipscing") -/// .page_size(-31) -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _project_id: String, - _history_id: String, - _execution_id: String, - _step_id: String, - _page_token: Option, - _page_size: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ListStepThumbnailsResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.executions.steps.thumbnails.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - params.push(("executionId", self._execution_id.to_string())); - params.push(("stepId", self._step_id.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._page_size { - params.push(("pageSize", value.to_string())); - } - for &field in ["alt", "projectId", "historyId", "executionId", "stepId", "pageToken", "pageSize"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}/executions/{executionId}/steps/{stepId}/thumbnails".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId"), ("{executionId}", "executionId"), ("{stepId}", "stepId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(4); - for param_name in ["stepId", "executionId", "historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A History id. - /// - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// An Execution id. - /// - /// Required. - /// - /// Sets the *execution id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn execution_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> { - self._execution_id = new_value.to_string(); - self - } - /// A Step id. - /// - /// Required. - /// - /// Sets the *step id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn step_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> { - self._step_id = new_value.to_string(); - self - } - /// A continuation token to resume the query at the next item. - /// - /// Optional. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of thumbnails to fetch. - /// - /// Default value: 50. The server will use this default if the field is not set or has a value of 0. - /// - /// Optional. - /// - /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> { - self._page_size = Some(new_value); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryExecutionStepThumbnailListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Gets an Execution. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the Execution does not exist -/// -/// A builder for the *histories.executions.get* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), auth); -/// // 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.projects().histories_executions_get("projectId", "historyId", "executionId") -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryExecutionGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _project_id: String, - _history_id: String, - _execution_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryExecutionGetCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryExecutionGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Execution)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.executions.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - params.push(("executionId", self._execution_id.to_string())); - for &field in ["alt", "projectId", "historyId", "executionId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}/executions/{executionId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId"), ("{executionId}", "executionId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["executionId", "historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryExecutionGetCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A History id. - /// - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryExecutionGetCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// An Execution id. - /// - /// Required. - /// - /// Sets the *execution id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn execution_id(mut self, new_value: &str) -> ProjectHistoryExecutionGetCall<'a, C, A> { - self._execution_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryExecutionGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryExecutionGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryExecutionGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates an existing Execution with the supplied partial entity. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the requested state transition is illegal - NOT_FOUND - if the containing History does not exist -/// -/// A builder for the *histories.executions.patch* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// use toolresults1_beta3::Execution; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), 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 = Execution::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.projects().histories_executions_patch(req, "projectId", "historyId", "executionId") -/// .request_id("diam") -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryExecutionPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _request: Execution, - _project_id: String, - _history_id: String, - _execution_id: String, - _request_id: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryExecutionPatchCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryExecutionPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Execution)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.executions.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - params.push(("executionId", self._execution_id.to_string())); - if let Some(value) = self._request_id { - params.push(("requestId", value.to_string())); - } - for &field in ["alt", "projectId", "historyId", "executionId", "requestId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}/executions/{executionId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId"), ("{executionId}", "executionId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["executionId", "historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Execution) -> ProjectHistoryExecutionPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// A Project id. Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryExecutionPatchCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryExecutionPatchCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// Required. - /// - /// Sets the *execution id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn execution_id(mut self, new_value: &str) -> ProjectHistoryExecutionPatchCall<'a, C, A> { - self._execution_id = new_value.to_string(); - self - } - /// A unique request ID for server to detect duplicated requests. For example, a UUID. - /// - /// Optional, but strongly recommended. - /// - /// Sets the *request id* query property to the given value. - pub fn request_id(mut self, new_value: &str) -> ProjectHistoryExecutionPatchCall<'a, C, A> { - self._request_id = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryExecutionPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryExecutionPatchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryExecutionPatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Lists Histories for a given Project. -/// -/// The histories are sorted by modification time in descending order. The history_id key will be used to order the history with the same modification time. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the History does not exist -/// -/// A builder for the *histories.list* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), auth); -/// // 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.projects().histories_list("projectId") -/// .page_token("Lorem") -/// .page_size(-21) -/// .filter_by_name("duo") -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _project_id: String, - _page_token: Option, - _page_size: Option, - _filter_by_name: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryListCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ListHistoriesResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._page_size { - params.push(("pageSize", value.to_string())); - } - if let Some(value) = self._filter_by_name { - params.push(("filterByName", value.to_string())); - } - for &field in ["alt", "projectId", "pageToken", "pageSize", "filterByName"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryListCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A continuation token to resume the query at the next item. - /// - /// Optional. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ProjectHistoryListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of Histories to fetch. - /// - /// Default value: 20. The server will use this default if the field is not set or has a value of 0. Any value greater than 100 will be treated as 100. - /// - /// Optional. - /// - /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> ProjectHistoryListCall<'a, C, A> { - self._page_size = Some(new_value); - self - } - /// If set, only return histories with the given name. - /// - /// Optional. - /// - /// Sets the *filter by name* query property to the given value. - pub fn filter_by_name(mut self, new_value: &str) -> ProjectHistoryListCall<'a, C, A> { - self._filter_by_name = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Gets a Step. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the Step does not exist -/// -/// A builder for the *histories.executions.steps.get* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), auth); -/// // 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.projects().histories_executions_steps_get("projectId", "historyId", "executionId", "stepId") -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryExecutionStepGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _project_id: String, - _history_id: String, - _execution_id: String, - _step_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryExecutionStepGetCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryExecutionStepGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Step)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.executions.steps.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - params.push(("executionId", self._execution_id.to_string())); - params.push(("stepId", self._step_id.to_string())); - for &field in ["alt", "projectId", "historyId", "executionId", "stepId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}/executions/{executionId}/steps/{stepId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId"), ("{executionId}", "executionId"), ("{stepId}", "stepId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(4); - for param_name in ["stepId", "executionId", "historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepGetCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A History id. - /// - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepGetCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// A Execution id. - /// - /// Required. - /// - /// Sets the *execution id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn execution_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepGetCall<'a, C, A> { - self._execution_id = new_value.to_string(); - self - } - /// A Step id. - /// - /// Required. - /// - /// Sets the *step id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn step_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepGetCall<'a, C, A> { - self._step_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryExecutionStepGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryExecutionStepGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryExecutionStepGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Publish xml files to an existing Step. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to write project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the requested state transition is illegal, e.g try to upload a duplicate xml file or a file too large. - NOT_FOUND - if the containing Execution does not exist -/// -/// A builder for the *histories.executions.steps.publishXunitXmlFiles* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// use toolresults1_beta3::PublishXunitXmlFilesRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), 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 = PublishXunitXmlFilesRequest::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.projects().histories_executions_steps_publish_xunit_xml_files(req, "projectId", "historyId", "executionId", "stepId") -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _request: PublishXunitXmlFilesRequest, - _project_id: String, - _history_id: String, - _execution_id: String, - _step_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Step)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.executions.steps.publishXunitXmlFiles", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - params.push(("executionId", self._execution_id.to_string())); - params.push(("stepId", self._step_id.to_string())); - for &field in ["alt", "projectId", "historyId", "executionId", "stepId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}/executions/{executionId}/steps/{stepId}:publishXunitXmlFiles".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId"), ("{executionId}", "executionId"), ("{stepId}", "stepId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(4); - for param_name in ["stepId", "executionId", "historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: PublishXunitXmlFilesRequest) -> ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> { - self._request = new_value; - self - } - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A History id. - /// - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// A Execution id. - /// - /// Required. - /// - /// Sets the *execution id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn execution_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> { - self._execution_id = new_value.to_string(); - self - } - /// A Step id. Note: This step must include a TestExecutionStep. - /// - /// Required. - /// - /// Sets the *step id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn step_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> { - self._step_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryExecutionStepPublishXunitXmlFileCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Lists Steps for a given Execution. -/// -/// The steps are sorted by creation_time in descending order. The step_id key will be used to order the steps with the same creation_time. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if an argument in the request happens to be invalid; e.g. if an attempt is made to list the children of a nonexistent Step - NOT_FOUND - if the containing Execution does not exist -/// -/// A builder for the *histories.executions.steps.list* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), auth); -/// // 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.projects().histories_executions_steps_list("projectId", "historyId", "executionId") -/// .page_token("labore") -/// .page_size(-39) -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryExecutionStepListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _project_id: String, - _history_id: String, - _execution_id: String, - _page_token: Option, - _page_size: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryExecutionStepListCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryExecutionStepListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ListStepsResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.executions.steps.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - params.push(("executionId", self._execution_id.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._page_size { - params.push(("pageSize", value.to_string())); - } - for &field in ["alt", "projectId", "historyId", "executionId", "pageToken", "pageSize"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}/executions/{executionId}/steps".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId"), ("{executionId}", "executionId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["executionId", "historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepListCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A History id. - /// - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepListCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// A Execution id. - /// - /// Required. - /// - /// Sets the *execution id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn execution_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepListCall<'a, C, A> { - self._execution_id = new_value.to_string(); - self - } - /// A continuation token to resume the query at the next item. - /// - /// Optional. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ProjectHistoryExecutionStepListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of Steps to fetch. - /// - /// Default value: 25. The server will use this default if the field is not set or has a value of 0. - /// - /// Optional. - /// - /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> ProjectHistoryExecutionStepListCall<'a, C, A> { - self._page_size = Some(new_value); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryExecutionStepListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryExecutionStepListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryExecutionStepListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates an existing Step with the supplied partial entity. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to write project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the requested state transition is illegal (e.g try to upload a duplicate xml file), if the updated step is too large (more than 10Mib) - NOT_FOUND - if the containing Execution does not exist -/// -/// A builder for the *histories.executions.steps.patch* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// use toolresults1_beta3::Step; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), 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 = Step::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.projects().histories_executions_steps_patch(req, "projectId", "historyId", "executionId", "stepId") -/// .request_id("Lorem") -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryExecutionStepPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _request: Step, - _project_id: String, - _history_id: String, - _execution_id: String, - _step_id: String, - _request_id: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryExecutionStepPatchCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryExecutionStepPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Step)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.executions.steps.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - params.push(("executionId", self._execution_id.to_string())); - params.push(("stepId", self._step_id.to_string())); - if let Some(value) = self._request_id { - params.push(("requestId", value.to_string())); - } - for &field in ["alt", "projectId", "historyId", "executionId", "stepId", "requestId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}/executions/{executionId}/steps/{stepId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId"), ("{executionId}", "executionId"), ("{stepId}", "stepId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(4); - for param_name in ["stepId", "executionId", "historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Step) -> ProjectHistoryExecutionStepPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepPatchCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A History id. - /// - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepPatchCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// A Execution id. - /// - /// Required. - /// - /// Sets the *execution id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn execution_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepPatchCall<'a, C, A> { - self._execution_id = new_value.to_string(); - self - } - /// A Step id. - /// - /// Required. - /// - /// Sets the *step id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn step_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepPatchCall<'a, C, A> { - self._step_id = new_value.to_string(); - self - } - /// A unique request ID for server to detect duplicated requests. For example, a UUID. - /// - /// Optional, but strongly recommended. - /// - /// Sets the *request id* query property to the given value. - pub fn request_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepPatchCall<'a, C, A> { - self._request_id = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryExecutionStepPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryExecutionStepPatchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryExecutionStepPatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates an Execution. -/// -/// The returned Execution will have the id set. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the containing History does not exist -/// -/// A builder for the *histories.executions.create* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// use toolresults1_beta3::Execution; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), 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 = Execution::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.projects().histories_executions_create(req, "projectId", "historyId") -/// .request_id("duo") -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryExecutionCreateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _request: Execution, - _project_id: String, - _history_id: String, - _request_id: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryExecutionCreateCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryExecutionCreateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Execution)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.executions.create", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - if let Some(value) = self._request_id { - params.push(("requestId", value.to_string())); - } - for &field in ["alt", "projectId", "historyId", "requestId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}/executions".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Execution) -> ProjectHistoryExecutionCreateCall<'a, C, A> { - self._request = new_value; - self - } - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryExecutionCreateCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A History id. - /// - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryExecutionCreateCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// A unique request ID for server to detect duplicated requests. For example, a UUID. - /// - /// Optional, but strongly recommended. - /// - /// Sets the *request id* query property to the given value. - pub fn request_id(mut self, new_value: &str) -> ProjectHistoryExecutionCreateCall<'a, C, A> { - self._request_id = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryExecutionCreateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryExecutionCreateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryExecutionCreateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a Step. -/// -/// The returned Step will have the id set. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - FAILED_PRECONDITION - if the step is too large (more than 10Mib) - NOT_FOUND - if the containing Execution does not exist -/// -/// A builder for the *histories.executions.steps.create* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// use toolresults1_beta3::Step; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), 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 = Step::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.projects().histories_executions_steps_create(req, "projectId", "historyId", "executionId") -/// .request_id("et") -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryExecutionStepCreateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _request: Step, - _project_id: String, - _history_id: String, - _execution_id: String, - _request_id: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryExecutionStepCreateCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryExecutionStepCreateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Step)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.executions.steps.create", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - params.push(("executionId", self._execution_id.to_string())); - if let Some(value) = self._request_id { - params.push(("requestId", value.to_string())); - } - for &field in ["alt", "projectId", "historyId", "executionId", "requestId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}/executions/{executionId}/steps".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId"), ("{executionId}", "executionId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["executionId", "historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: Step) -> ProjectHistoryExecutionStepCreateCall<'a, C, A> { - self._request = new_value; - self - } - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepCreateCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A History id. - /// - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepCreateCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// A Execution id. - /// - /// Required. - /// - /// Sets the *execution id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn execution_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepCreateCall<'a, C, A> { - self._execution_id = new_value.to_string(); - self - } - /// A unique request ID for server to detect duplicated requests. For example, a UUID. - /// - /// Optional, but strongly recommended. - /// - /// Sets the *request id* query property to the given value. - pub fn request_id(mut self, new_value: &str) -> ProjectHistoryExecutionStepCreateCall<'a, C, A> { - self._request_id = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryExecutionStepCreateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryExecutionStepCreateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryExecutionStepCreateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Gets the Tool Results settings for a project. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to read from project -/// -/// A builder for the *getSettings* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), auth); -/// // 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.projects().get_settings("projectId") -/// .doit(); -/// # } -/// ``` -pub struct ProjectGetSettingCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _project_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectGetSettingCall<'a, C, A> {} - -impl<'a, C, A> ProjectGetSettingCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ProjectSettings)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.getSettings", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - for &field in ["alt", "projectId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/settings".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectGetSettingCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectGetSettingCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectGetSettingCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectGetSettingCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Lists Histories for a given Project. -/// -/// The executions are sorted by creation_time in descending order. The execution_id key will be used to order the executions with the same creation_time. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to read project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the containing History does not exist -/// -/// A builder for the *histories.executions.list* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), auth); -/// // 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.projects().histories_executions_list("projectId", "historyId") -/// .page_token("ut") -/// .page_size(-16) -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryExecutionListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _project_id: String, - _history_id: String, - _page_token: Option, - _page_size: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryExecutionListCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryExecutionListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ListExecutionsResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.executions.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("historyId", self._history_id.to_string())); - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._page_size { - params.push(("pageSize", value.to_string())); - } - for &field in ["alt", "projectId", "historyId", "pageToken", "pageSize"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories/{historyId}/executions".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{historyId}", "historyId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["historyId", "projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryExecutionListCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A History id. - /// - /// Required. - /// - /// Sets the *history id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn history_id(mut self, new_value: &str) -> ProjectHistoryExecutionListCall<'a, C, A> { - self._history_id = new_value.to_string(); - self - } - /// A continuation token to resume the query at the next item. - /// - /// Optional. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ProjectHistoryExecutionListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of Executions to fetch. - /// - /// Default value: 25. The server will use this default if the field is not set or has a value of 0. - /// - /// Optional. - /// - /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> ProjectHistoryExecutionListCall<'a, C, A> { - self._page_size = Some(new_value); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryExecutionListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryExecutionListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryExecutionListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Creates a History. -/// -/// The returned History will have the id set. -/// -/// May return any of the following canonical error codes: -/// -/// - PERMISSION_DENIED - if the user is not authorized to write to project - INVALID_ARGUMENT - if the request is malformed - NOT_FOUND - if the containing project does not exist -/// -/// A builder for the *histories.create* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_toolresults1_beta3 as toolresults1_beta3; -/// use toolresults1_beta3::History; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use toolresults1_beta3::ToolResults; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ToolResults::new(hyper::Client::new(), 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 = History::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.projects().histories_create(req, "projectId") -/// .request_id("dolor") -/// .doit(); -/// # } -/// ``` -pub struct ProjectHistoryCreateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ToolResults, - _request: History, - _project_id: String, - _request_id: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectHistoryCreateCall<'a, C, A> {} - -impl<'a, C, A> ProjectHistoryCreateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, History)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "toolresults.projects.histories.create", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - if let Some(value) = self._request_id { - params.push(("requestId", value.to_string())); - } - for &field in ["alt", "projectId", "requestId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/toolresults/v1beta3/projects/{projectId}/histories".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["projectId"].iter() { - if let Some(index) = params.iter().position(|t| &t.0 == param_name) { - indices_for_removal.push(index); - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params)); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = - { - let mut value = json::value::to_value(&self._request); - remove_json_null_values(&mut value); - let mut dst = io::Cursor::new(Vec::with_capacity(128)); - json::to_writer(&mut dst, &value).unwrap(); - dst - }; - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { - Ok(token) => token, - Err(err) => { - match dlg.token(&*err) { - Some(token) => token, - None => { - dlg.finished(false); - return Err(Error::MissingToken(err)) - } - } - } - }; - let auth_header = Authorization(Bearer { token: token.access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep(d); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, - json::from_str(&json_err).ok(), - json::from_str(&json_err).ok()) { - sleep(d); - continue; - } - dlg.finished(false); - return match json::from_str::(&json_err){ - Err(_) => Err(Error::Failure(res)), - Ok(serr) => Err(Error::BadRequest(serr)) - } - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(json_response, err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: History) -> ProjectHistoryCreateCall<'a, C, A> { - self._request = new_value; - self - } - /// A Project id. - /// - /// Required. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectHistoryCreateCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// A unique request ID for server to detect duplicated requests. For example, a UUID. - /// - /// Optional, but strongly recommended. - /// - /// Sets the *request id* query property to the given value. - pub fn request_id(mut self, new_value: &str) -> ProjectHistoryCreateCall<'a, C, A> { - self._request_id = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectHistoryCreateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *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. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param(mut self, name: T, value: T) -> ProjectHistoryCreateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectHistoryCreateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - diff --git a/gen/translate2-cli/Cargo.toml b/gen/translate2-cli/Cargo.toml index b8f95487fe..7fd4f03da7 100644 --- a/gen/translate2-cli/Cargo.toml +++ b/gen/translate2-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-translate2-cli" -version = "0.3.6+20160627" +version = "1.0.0+20160627" authors = ["Sebastian Thiel "] description = "A complete library to interact with translate (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/translate2-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-translate2/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-translate2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-translate2/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-translate2] path = "../translate2" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/translate2-cli/README.md b/gen/translate2-cli/README.md index 7eebed8275..5be5e7b0c6 100644 --- a/gen/translate2-cli/README.md +++ b/gen/translate2-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *translate* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/translate2.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/translate2.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/translate2.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/translate2.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/translate2-cli). # Usage -This documentation was generated from the *translate* API at revision *20160627*. The CLI is at version *0.3.6*. +This documentation was generated from the *translate* API at revision *20160627*. The CLI is at version *1.0.0*. ```bash translate2 [options] diff --git a/gen/translate2-cli/mkdocs.yml b/gen/translate2-cli/mkdocs.yml index 7887238a5a..99fa1b0a5c 100644 --- a/gen/translate2-cli/mkdocs.yml +++ b/gen/translate2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: translate v0.3.6+20160627 +site_name: translate v1.0.0+20160627 site_url: http://byron.github.io/google-apis-rs/google-translate2-cli site_description: Write integrating applications with bcore diff --git a/gen/translate2-cli/src/main.rs b/gen/translate2-cli/src/main.rs index 03eb727b1b..10df6240d5 100644 --- a/gen/translate2-cli/src/main.rs +++ b/gen/translate2-cli/src/main.rs @@ -405,7 +405,7 @@ fn main() { let mut app = App::new("translate2") .author("Sebastian Thiel ") - .version("0.3.6+20160627") + .version("1.0.0+20160627") .about("Translates text from one language to another.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_translate2_cli") .arg(Arg::with_name("folder") diff --git a/gen/urlshortener1-cli/Cargo.toml b/gen/urlshortener1-cli/Cargo.toml index 31136f79cb..48e3441121 100644 --- a/gen/urlshortener1-cli/Cargo.toml +++ b/gen/urlshortener1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-urlshortener1-cli" -version = "0.3.6+20150519" +version = "1.0.0+20150519" authors = ["Sebastian Thiel "] description = "A complete library to interact with urlshortener (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/urlshortener1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-urlshortener1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-urlshortener1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-urlshortener1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-urlshortener1] path = "../urlshortener1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/urlshortener1-cli/README.md b/gen/urlshortener1-cli/README.md index a83941de65..655dad2b41 100644 --- a/gen/urlshortener1-cli/README.md +++ b/gen/urlshortener1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *urlshortener* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/urlshortener1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/urlshortener1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/urlshortener1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/urlshortener1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/urlshortener1-cli). # Usage -This documentation was generated from the *urlshortener* API at revision *20150519*. The CLI is at version *0.3.6*. +This documentation was generated from the *urlshortener* API at revision *20150519*. The CLI is at version *1.0.0*. ```bash urlshortener1 [options] diff --git a/gen/urlshortener1-cli/mkdocs.yml b/gen/urlshortener1-cli/mkdocs.yml index 2e89e6850b..07c76cfa10 100644 --- a/gen/urlshortener1-cli/mkdocs.yml +++ b/gen/urlshortener1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: urlshortener v0.3.6+20150519 +site_name: urlshortener v1.0.0+20150519 site_url: http://byron.github.io/google-apis-rs/google-urlshortener1-cli site_description: Write integrating applications with bcore diff --git a/gen/urlshortener1-cli/src/main.rs b/gen/urlshortener1-cli/src/main.rs index d2ad6c90ca..8dbe1b93b3 100644 --- a/gen/urlshortener1-cli/src/main.rs +++ b/gen/urlshortener1-cli/src/main.rs @@ -430,7 +430,7 @@ fn main() { let mut app = App::new("urlshortener1") .author("Sebastian Thiel ") - .version("0.3.6+20150519") + .version("1.0.0+20150519") .about("Lets you create, inspect, and manage goo.gl short URLs") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_urlshortener1_cli") .arg(Arg::with_name("url") diff --git a/gen/webfonts1-cli/Cargo.toml b/gen/webfonts1-cli/Cargo.toml index 6e838a4962..6d9cc465af 100644 --- a/gen/webfonts1-cli/Cargo.toml +++ b/gen/webfonts1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-webfonts1-cli" -version = "0.3.6+20160302" +version = "1.0.0+20160302" authors = ["Sebastian Thiel "] description = "A complete library to interact with webfonts (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/webfonts1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-webfonts1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-webfonts1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-webfonts1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-webfonts1] path = "../webfonts1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/webfonts1-cli/README.md b/gen/webfonts1-cli/README.md index 41ad47ca4d..2072df4bb5 100644 --- a/gen/webfonts1-cli/README.md +++ b/gen/webfonts1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *webfonts* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/webfonts1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/webfonts1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/webfonts1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/webfonts1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/webfonts1-cli). # Usage -This documentation was generated from the *webfonts* API at revision *20160302*. The CLI is at version *0.3.6*. +This documentation was generated from the *webfonts* API at revision *20160302*. The CLI is at version *1.0.0*. ```bash webfonts1 [options] diff --git a/gen/webfonts1-cli/mkdocs.yml b/gen/webfonts1-cli/mkdocs.yml index 6a9691345b..3d74133705 100644 --- a/gen/webfonts1-cli/mkdocs.yml +++ b/gen/webfonts1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: webfonts v0.3.6+20160302 +site_name: webfonts v1.0.0+20160302 site_url: http://byron.github.io/google-apis-rs/google-webfonts1-cli site_description: Write integrating applications with bcore diff --git a/gen/webfonts1-cli/src/main.rs b/gen/webfonts1-cli/src/main.rs index 0f96d740e6..4f4147b273 100644 --- a/gen/webfonts1-cli/src/main.rs +++ b/gen/webfonts1-cli/src/main.rs @@ -219,7 +219,7 @@ fn main() { let mut app = App::new("webfonts1") .author("Sebastian Thiel ") - .version("0.3.6+20160302") + .version("1.0.0+20160302") .about("Accesses the metadata for all families served by Google Fonts, providing a list of families currently available (including available styles and a list of supported script subsets).") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_webfonts1_cli") .arg(Arg::with_name("folder") diff --git a/gen/webmasters3-cli/Cargo.toml b/gen/webmasters3-cli/Cargo.toml index 662c9b9d84..806546c0ad 100644 --- a/gen/webmasters3-cli/Cargo.toml +++ b/gen/webmasters3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-webmasters3-cli" -version = "0.3.6+20160317" +version = "1.0.0+20160317" authors = ["Sebastian Thiel "] description = "A complete library to interact with webmasters (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/webmasters3-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-webmasters3/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-webmasters3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-webmasters3/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-webmasters3] path = "../webmasters3" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/webmasters3-cli/README.md b/gen/webmasters3-cli/README.md index 68bb2f2ab0..84148d311a 100644 --- a/gen/webmasters3-cli/README.md +++ b/gen/webmasters3-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *webmasters* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/webmasters3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/webmasters3.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/webmasters3.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/webmasters3.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/webmasters3-cli). # Usage -This documentation was generated from the *webmasters* API at revision *20160317*. The CLI is at version *0.3.6*. +This documentation was generated from the *webmasters* API at revision *20160317*. The CLI is at version *1.0.0*. ```bash webmasters3 [options] diff --git a/gen/webmasters3-cli/mkdocs.yml b/gen/webmasters3-cli/mkdocs.yml index 984bc37ea4..da782d4f03 100644 --- a/gen/webmasters3-cli/mkdocs.yml +++ b/gen/webmasters3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: webmasters v0.3.6+20160317 +site_name: webmasters v1.0.0+20160317 site_url: http://byron.github.io/google-apis-rs/google-webmasters3-cli site_description: Write integrating applications with bcore diff --git a/gen/webmasters3-cli/src/main.rs b/gen/webmasters3-cli/src/main.rs index a240876fc2..dab329ff83 100644 --- a/gen/webmasters3-cli/src/main.rs +++ b/gen/webmasters3-cli/src/main.rs @@ -1243,7 +1243,7 @@ fn main() { let mut app = App::new("webmasters3") .author("Sebastian Thiel ") - .version("0.3.6+20160317") + .version("1.0.0+20160317") .about("View Google Search Console data for your verified sites.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_webmasters3_cli") .arg(Arg::with_name("url") diff --git a/gen/youtube3-cli/Cargo.toml b/gen/youtube3-cli/Cargo.toml index 94cc65fa8c..9eac91d230 100644 --- a/gen/youtube3-cli/Cargo.toml +++ b/gen/youtube3-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-youtube3-cli" -version = "0.3.6+20160805" +version = "1.0.0+20160805" authors = ["Sebastian Thiel "] description = "A complete library to interact with YouTube (protocol v3)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/youtube3-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-youtube3/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-youtube3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-youtube3/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-youtube3] path = "../youtube3" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/youtube3-cli/README.md b/gen/youtube3-cli/README.md index 32f646b7cd..562834c076 100644 --- a/gen/youtube3-cli/README.md +++ b/gen/youtube3-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *YouTube* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/youtube3.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/youtube3.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/youtube3.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/youtube3.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/youtube3-cli). # Usage -This documentation was generated from the *YouTube* API at revision *20160805*. The CLI is at version *0.3.6*. +This documentation was generated from the *YouTube* API at revision *20160805*. The CLI is at version *1.0.0*. ```bash youtube3 [options] diff --git a/gen/youtube3-cli/mkdocs.yml b/gen/youtube3-cli/mkdocs.yml index e1a8db89d4..489b3443bc 100644 --- a/gen/youtube3-cli/mkdocs.yml +++ b/gen/youtube3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: YouTube v0.3.6+20160805 +site_name: YouTube v1.0.0+20160805 site_url: http://byron.github.io/google-apis-rs/google-youtube3-cli site_description: Write integrating applications with bcore diff --git a/gen/youtube3-cli/src/main.rs b/gen/youtube3-cli/src/main.rs index 3373edb661..7c93bf05ad 100644 --- a/gen/youtube3-cli/src/main.rs +++ b/gen/youtube3-cli/src/main.rs @@ -8352,7 +8352,7 @@ fn main() { let mut app = App::new("youtube3") .author("Sebastian Thiel ") - .version("0.3.6+20160805") + .version("1.0.0+20160805") .about("Supports core YouTube features, such as uploading videos, creating and managing playlists, searching for content, and much more.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_youtube3_cli") .arg(Arg::with_name("url") diff --git a/gen/youtubeanalytics1-cli/Cargo.toml b/gen/youtubeanalytics1-cli/Cargo.toml index af2c8fccf2..0ae854f68e 100644 --- a/gen/youtubeanalytics1-cli/Cargo.toml +++ b/gen/youtubeanalytics1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-youtubeanalytics1-cli" -version = "0.3.6+20160513" +version = "1.0.0+20160513" authors = ["Sebastian Thiel "] description = "A complete library to interact with YouTube Analytics (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/youtubeanalytics1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-youtubeanalytics1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-youtubeanalytics1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-youtubeanalytics1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-youtubeanalytics1] path = "../youtubeanalytics1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/youtubeanalytics1-cli/README.md b/gen/youtubeanalytics1-cli/README.md index cc323cc174..46193b52a3 100644 --- a/gen/youtubeanalytics1-cli/README.md +++ b/gen/youtubeanalytics1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *YouTube Analytics* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/youtubeanalytics1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/youtubeanalytics1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/youtubeanalytics1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/youtubeanalytics1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/youtubeanalytics1-cli). # Usage -This documentation was generated from the *YouTube Analytics* API at revision *20160513*. The CLI is at version *0.3.6*. +This documentation was generated from the *YouTube Analytics* API at revision *20160513*. The CLI is at version *1.0.0*. ```bash youtubeanalytics1 [options] diff --git a/gen/youtubeanalytics1-cli/mkdocs.yml b/gen/youtubeanalytics1-cli/mkdocs.yml index 3da5f3d8c7..be43be20df 100644 --- a/gen/youtubeanalytics1-cli/mkdocs.yml +++ b/gen/youtubeanalytics1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: YouTube Analytics v0.3.6+20160513 +site_name: YouTube Analytics v1.0.0+20160513 site_url: http://byron.github.io/google-apis-rs/google-youtubeanalytics1-cli site_description: Write integrating applications with bcore diff --git a/gen/youtubeanalytics1-cli/src/main.rs b/gen/youtubeanalytics1-cli/src/main.rs index 3640b6b4d2..618276f056 100644 --- a/gen/youtubeanalytics1-cli/src/main.rs +++ b/gen/youtubeanalytics1-cli/src/main.rs @@ -1125,7 +1125,7 @@ fn main() { let mut app = App::new("youtubeanalytics1") .author("Sebastian Thiel ") - .version("0.3.6+20160513") + .version("1.0.0+20160513") .about("Retrieves your YouTube Analytics data.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_youtubeanalytics1_cli") .arg(Arg::with_name("url") diff --git a/gen/youtubereporting1-cli/Cargo.toml b/gen/youtubereporting1-cli/Cargo.toml index 58021f5995..aa2fe13267 100644 --- a/gen/youtubereporting1-cli/Cargo.toml +++ b/gen/youtubereporting1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-youtubereporting1-cli" -version = "0.3.6+20160719" +version = "1.0.0+20160719" authors = ["Sebastian Thiel "] description = "A complete library to interact with YouTube Reporting (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/youtubereporting1-cli" @@ -21,15 +21,15 @@ hyper = "^ 0.9" mime = "^ 0.2.0" serde = "^ 0.8" serde_json = "^ 0.8" -yup-oauth2 = { version = "^ 0.6", optional = true, default-features = false } -serde_macros = { version = "^ 0.8", optional = true } +yup-oauth2 = { version = "^ 1.0", optional = true, default-features = false } +serde_derive = { version = "^ 0.8", optional = true } strsim = "^0.5" yup-hyper-mock = "^1.0" clap = "^2.0" [features] default = ["with-serde-codegen"] -nightly = ["serde_macros","yup-oauth2/nightly","google-youtubereporting1/nightly"] +nightly = ["serde_derive","yup-oauth2/nightly","google-youtubereporting1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-youtubereporting1/with-serde-codegen"] [build-dependencies] @@ -38,6 +38,6 @@ serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-youtubereporting1] path = "../youtubereporting1" -version = "0.1.15" +version = "1.0.0" optional = true default-features = false diff --git a/gen/youtubereporting1-cli/README.md b/gen/youtubereporting1-cli/README.md index 476b0eefdc..64a446e10a 100644 --- a/gen/youtubereporting1-cli/README.md +++ b/gen/youtubereporting1-cli/README.md @@ -17,14 +17,14 @@ Everything else about the *YouTube Reporting* API can be found at the You can download the pre-compiled 64bit binaries for the following platforms: -* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/0.3.6/ubuntu/youtubereporting1.tar.gz) -* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/0.3.6/osx/youtubereporting1.tar.gz) +* ![icon](http://megaicons.net/static/img/icons_sizes/6/140/16/ubuntu-icon.png) [ubuntu](http://dl.byronimo.de/google.rs/cli/1.0.0/ubuntu/youtubereporting1.tar.gz) +* ![icon](http://hydra-media.cursecdn.com/wow.gamepedia.com/a/a2/Apple-icon-16x16.png?version=25ddd67ac3dd3b634478e3978b76cb74) [osx](http://dl.byronimo.de/google.rs/cli/1.0.0/osx/youtubereporting1.tar.gz) Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/youtubereporting1-cli). # Usage -This documentation was generated from the *YouTube Reporting* API at revision *20160719*. The CLI is at version *0.3.6*. +This documentation was generated from the *YouTube Reporting* API at revision *20160719*. The CLI is at version *1.0.0*. ```bash youtubereporting1 [options] diff --git a/gen/youtubereporting1-cli/mkdocs.yml b/gen/youtubereporting1-cli/mkdocs.yml index 7e8b56c9e0..80dc699a81 100644 --- a/gen/youtubereporting1-cli/mkdocs.yml +++ b/gen/youtubereporting1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: YouTube Reporting v0.3.6+20160719 +site_name: YouTube Reporting v1.0.0+20160719 site_url: http://byron.github.io/google-apis-rs/google-youtubereporting1-cli site_description: Write integrating applications with bcore diff --git a/gen/youtubereporting1-cli/src/main.rs b/gen/youtubereporting1-cli/src/main.rs index 83989c87fa..980679b753 100644 --- a/gen/youtubereporting1-cli/src/main.rs +++ b/gen/youtubereporting1-cli/src/main.rs @@ -891,7 +891,7 @@ fn main() { let mut app = App::new("youtubereporting1") .author("Sebastian Thiel ") - .version("0.3.6+20160719") + .version("1.0.0+20160719") .about("Schedules reporting jobs containing your YouTube Analytics data and downloads the resulting bulk data reports in the form of CSV files.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_youtubereporting1_cli") .arg(Arg::with_name("url")